Skip to main content

Cars plugin to use the MoGe2 model for edge detection

Project description

Edge Detection plugin for CARS

This plugin enables the use of the MoGe2 model in CARS, for higher accuracy building reconstruction.

Context

This plugin is made to be used in conjunction with CARS, the stereo-reconstruction software. More information can be found over at CARS's GitHub page.

Installation

First clone this repository, using :

$ git clone --recurse-submodules git@gitlab.cnes.fr:dali/cars-park/cars-plugins/cars-edge-detection-plugin.git
$ cd cars-edge-detection-plugin   

Note: --recurse-submodules is required. This project vendors MoGe as a submodule, and MoGe itself vendors utils3d and pipeline as nested submodules. A plain git clone will leave those directories empty, causing build failures.

If you already cloned the repository without submodules, initialize them before installing:

$ git submodule update --init --recursive

You can then create a virtual environment and install the plugin, which will install CARS automatically :

$ python3 -m venv venv
$ source venv/bin/activate
$ make install   

Or install the plugin in your own environment, if it already has CARS :

$ source your/own/env/activate
$ pip install .

Once installed, don't forget to download a MoGe2 model, for example Ruicheng/moge-2-vitl-normal, using this command :

$ cars-download-moge2 --model vitl-normal

Or via any other means if you don't have a direct access to the internet. The plugin will attempt to download the vitl-normal model on first import, providing at least the default model. If working from an environment such as the TREX cluster, an option is to directly use wget to fetch the model file, then move it to its proper place for the plugin to recognize it :

# fetch the model
$ wget https://huggingface.co/Ruicheng/moge-2-vitl-normal/resolve/main/model.pt

# move the model to the right place
# it should be under cars_edge_detection_plugin/applications/depth_map_generation/models with the proper name for each model :
#  - moge-2-vitl-normal.pt
#  - moge-2-vitb-normal.pt
#  - moge-2-vits-normal.pt
$ mkdir [your/plugin/installation/path/]cars_edge_detection_plugin/applications/depth_map_generation/models
$ mv ./model.pt [your/plugin/installation/path/]cars_edge_detection_plugin/applications/depth_map_generation/models/moge-2-vitl-normal.pt

Using the new pipeline

Though this pipeline is intended to be used within CARS's meta pipeline, it can still be used as a stand-alone pipeline by providing the right configuration.

Once your configuration file is ready, you can launch the pipeline using CARS :

$ cars configfile.yaml

Configuration

The edge detection pipeline can be enabled by setting the pipeline parameter in the global advanced section of the CARS configuration.

A minimal example configuration is shown below:

input:
  sensors:
    one: # sensor image path
    two: # sensor image path
pipeline: edge_detection
output:
  directory: outresults

The pipeline operates on image pairs. By default, edge detection is only computed where required by downstream applications, meaning on the left images only.

Additional options specific to the edge detection pipeline can be configured under the edge_detection section. For example, edge detection can also be applied to right images, and the MoGe2-based depth map generation application can be configured as follows:

input: ...
advanced: ...
output: ...
edge_detection:
  advanced:
    save_intermediate_data: false
    right_image_edge_detection: true
  applications:
    depth_map_generation:
      method: moge2
      model: Ruicheng/moge-2-vitl-normal
      save_intermediate_data: true
      edge_threshold: 0.7

The model parameter can reference either a local MoGe2 checkpoint or a Hugging Face model identifier.

If save_intermediate_data is set to false, only the edge map will be created in the output folder. Else, all by-products (depth map, normal map, tile_id) will be saved in the dump_dir folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cars_edge_detection_plugin-0.1.1rc0.tar.gz (4.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cars_edge_detection_plugin-0.1.1rc0-py3-none-any.whl (258.3 kB view details)

Uploaded Python 3

File details

Details for the file cars_edge_detection_plugin-0.1.1rc0.tar.gz.

File metadata

File hashes

Hashes for cars_edge_detection_plugin-0.1.1rc0.tar.gz
Algorithm Hash digest
SHA256 44284eb842a1a0aa07338ccdb32d706c201f939b9c8845bc070fce1b8a64b7c9
MD5 fffda29f4f6ce3d7dde4a6118380d8d3
BLAKE2b-256 ad6457abd493d074bdc652321239ff566a4c8b3d811c14141da864cf976d9591

See more details on using hashes here.

File details

Details for the file cars_edge_detection_plugin-0.1.1rc0-py3-none-any.whl.

File metadata

File hashes

Hashes for cars_edge_detection_plugin-0.1.1rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 62f2961d8d272436df98945943ea0b69db74fa22500aedfc922ec304a460e723
MD5 187cc75a871279ff99466069ef4adf30
BLAKE2b-256 75af91f6666cf6af13029f913d93243b199a7e1b11482af80b0295751ff0626d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page