Skip to content

Conversation

@dlichy
Copy link

@dlichy dlichy commented Apr 14, 2025

This pull request adds several new capabilities to the run_reconstruction function:

  1. (Issue Downsample/Normalize resolution of photoscan reconstruction inputs #277) Adds a new argument new_width that resizes the images to the specified width while maintaining the aspect ratio.

  2. (Issue Photoscan background removal #267) Adds an argument use_mask. When set to True, this runs MODNet on each image to obtain a background mask. The mask is then used to filter the depth maps during reconstruction with Meshroom.

    To use this feature:

    • Download the MODNet ONNX checkpoint from this link.
    • Set the environment variable MODNET_PATH to the path of the downloaded checkpoint, e.g.:
      MODNET_PATH=path/to/modnet_photographic_portrait_matting.onnx
  3. (Issue Meshroom pipeline optimization #271) Adds a new argument pipeline_name that specifies one of the custom pipelines located in the meshroom_pipelines folder.

Daniel and others added 6 commits April 16, 2025 23:50
This commit also changes the signature of run_reconstruction to:

run_reconstruction(images: list[Path],
                   pipeline_name: str = "default_pipeline"
)-> Tuple[Photoscan, Path]

Here, pipeline_name is now a string representing the name of a .mg
pipeline in the meshroom_pipelines folder.
These warnings break the CI on windows11 python3.12, because we
configure our pytest to treat all warnings as errors.
There is a chance that the ONNX runtime support limitation warnings
are not actually harmful to the user and just indicate a lack of
official testing and support from Microsoft:
microsoft/onnxruntime#20001 (comment)
@ebrahimebrahim ebrahimebrahim force-pushed the issue_271_meshroom_pipelines branch from ad0cb71 to 2ee2676 Compare April 17, 2025 03:50
@ebrahimebrahim ebrahimebrahim force-pushed the issue_271_meshroom_pipelines branch from 2ee2676 to 09b88a4 Compare April 17, 2025 04:04
Copy link
Collaborator

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Things ran very smoothly. The code is clean. Several changes requested, including two sections for which I think unit testing will pay off.

Note that I force-pushed to rebase to main, and I also pushed a couple of minor things, so please reset your local version of this branch to here before you continue working. I won't mess with the branch again without prior warning 😄

"""Get the MODNet checkpoint path. Download it if not present.
"""
package = "openlifu.trk.modnet_checkpoints"
filename = "modnet_photographic_portrait_matting.onnx"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add src/openlifu/trk/modnet_checkpoints/modnet_photographic_portrait_matting.onnx to the .gitignore at the top level of this repo

or maybe more generally just *.onnx?

@ebrahimebrahim ebrahimebrahim self-requested a review April 17, 2025 20:19
@ebrahimebrahim ebrahimebrahim force-pushed the issue_271_meshroom_pipelines branch from cf1718e to 9e8786b Compare April 18, 2025 18:55
Copy link
Collaborator

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything works seamlessly, and many thanks for the unit tests!

Comment on lines +172 to +176
# Test inverse is consistent
for orientation in range(9):
img_tform = apply_exif_orientation_numpy(img, orientation)
img_recon = apply_exif_orientation_numpy(img_tform, orientation, inverse=True)
np.testing.assert_array_equal(img, img_recon)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(excellent!)

@ebrahimebrahim ebrahimebrahim merged commit 37a2f43 into main Apr 18, 2025
9 checks passed
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.

Downsample/Normalize resolution of photoscan reconstruction inputs Meshroom pipeline optimization Photoscan background removal

3 participants