Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Headless Dockerfile & configure GH action to build & push #1908

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

hammady
Copy link
Contributor

@hammady hammady commented Feb 26, 2023

Description

This PR introduces the following:

  1. A brand new Dockerfile (docker/Dockerfile_ubuntu_headless) to build Meshroom (headless) from scratch on the latest Ubuntu and CUDA. Headless means only the meshroom python package and binaries (e.g. meshroom_batch). This is much smaller, simpler and more secure than the fully fledged Qt build. This was done because there are some use cases where one wants to embed meshroom in their Python code without requiring the heavy dependency on Qt.
  2. A new GitHub action which automatically builds a docker image and pushes it to ghcr.io on every push to the specified branches. This requires a secret to be configured by the repo owner: GHCR_PUSH_TOKEN which is a PAT with the packages:write action. This can be easily changed to push to Docker Hub if desired (or both). This has been tested on my fork (check here) where I invoked the meshroom_batch command on the official monstree full dataset.
  3. Removed dependency on the docker/build* scripts which is not the recommended way of invoking docker builds as they should be self-contained and independent of the host OS.

Features list

  1. New Docker build for headless mode
  2. New GitHub action

Implementation remarks

Here is an example Python app that mimics the meshroom_batch binary assuming only the --input and --output arguments are passed:

from meshroom.core.graph import Graph, GraphModification, executeGraph


def execute_pipeline(input_dir, output_dir, name, pipeline_file):
    # create an empty graph
    graph = Graph(name=name)

    # update attributes of the graph (input dir, output dir and pipeline to load)
    with GraphModification(graph):
        # load graph template from the pipeline file
        graph.load(pipeline_file, setupProjectFile=False)

        # get init node and initialize it with input directory
        initNode = graph.findInitNodes()[0]
        initNode.nodeDesc.initialize(initNode, input_dir, [])

        # get publish node and set output directory
        publishNode = graph.nodesOfType('Publish')[0]
        publishNode.output.value = output_dir

    # start computation
    executeGraph(graph)

execute_pipeline(input_dir='/input', output_dir='/output',
    name='someweirdnameishere', pipeline_file='/home/pipeline.mg')

Note that GLTF generates an additional .bin file.
For this, I had to include .* in the output file pattern.
An alternative was to add an additional output parameter to be
enabled only when GLTF is selected (like the MTL file).
Also note that with this .* pattern, the MTL output is redundant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant