3DOM-FBK / deep-image-matching

Multiview matching with deep-learning and hand-crafted local features for COLMAP and other SfM software. Supports high-resolution formats and images with rotations. Both CLI and GUI are supported.
https://3dom-fbk.github.io/deep-image-matching/
BSD 3-Clause "New" or "Revised" License
294 stars 31 forks source link

cannot find file when run in Colab #56

Closed pengxutao closed 3 months ago

pengxutao commented 3 months ago

hello, when I run [colab_run_from_bash_example.ipynb] in Colab, here is an error:

Snipaste_2024-04-05_16-51-52 Snipaste_2024-04-05_16-53-31 Snipaste_2024-04-05_16-54-43 As you can see, install deep-image-matching and run python3 deep-image-matching/main.py --help is OK, but when I run python3 ./deep-image-matching/main.py \ --dir ./deep-image-matching/assets/pytest \ --pipeline sift+kornia_matcher \ --skip_reconstruction here is an error:

2024-04-05 09:03:55 | [INFO    ] Running image matching with the following configuration:
2024-04-05 09:03:55 | [INFO    ]   Image folder: deep-image-matching/assets/pytest/images
2024-04-05 09:03:55 | [INFO    ]   Output folder: deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high
2024-04-05 09:03:55 | [INFO    ]   Number of images: 3
2024-04-05 09:03:55 | [INFO    ]   Matching strategy: matching_lowres
2024-04-05 09:03:55 | [INFO    ]   Image quality: HIGH
2024-04-05 09:03:55 | [INFO    ]   Tile selection: NONE
2024-04-05 09:03:55 | [INFO    ]   Feature extraction method: sift
2024-04-05 09:03:55 | [INFO    ]   Matching method: kornia_matcher
2024-04-05 09:03:55 | [INFO    ]   Geometric verification: PYDEGENSAC
2024-04-05 09:03:55 | [INFO    ]   CUDA available: True
2024-04-05 09:03:55 | [INFO    ] Low resolution matching, generating pairs ..
Loaded SuperPoint model
2024-04-05 09:03:56 | [INFO    ] Extracting features from downsampled images...
2024-04-05 09:03:57 | [INFO    ] Matching downsampled images...
2024-04-05 09:03:58 | [INFO    ] Found 3 pairs.
2024-04-05 09:03:58 | [INFO    ] Extracting features with sift...
2024-04-05 09:03:58 | [INFO    ] sift configuration: 
{'name': 'sift'}
2024-04-05 09:04:00 | [INFO    ] Features extracted!
2024-04-05 09:04:00 | [INFO    ] Matching features with kornia_matcher...
2024-04-05 09:04:00 | [INFO    ] kornia_matcher configuration: 
{'match_mode': 'smnn', 'name': 'kornia_matcher', 'th': 0.85}
2024-04-05 09:04:00 | [INFO    ] Matching features...
2024-04-05 09:04:00 | [INFO    ] 
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
Downloading: "https://github.com/cvg/LightGlue/releases/download/v0.1_arxiv/superpoint_v1.pth" to /root/.cache/torch/hub/checkpoints/superpoint_v1.pth
100%|██████████| 4.96M/4.96M [00:00<00:00, 98.3MB/s]
Downloading: "https://github.com/cvg/LightGlue/releases/download/v0.1_arxiv/superpoint_lightglue.pth" to /root/.cache/torch/hub/checkpoints/superpoint_lightglue_v0-1_arxiv.pth
100%|██████████| 45.3M/45.3M [00:00<00:00, 226MB/s]
100%|██████████| 3/3 [00:00<00:00,  3.16it/s]
100%|██████████| 3/3 [00:00<00:00,  3.49it/s]
100%|██████████| 3/3 [00:01<00:00,  2.46it/s]
100%|██████████| 3/3 [00:01<00:00,  2.67it/s]
Traceback (most recent call last):
  File "/content/./deep-image-matching/main.py", line 58, in <module>
    with open(config.general["camera_options"], "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: './config/cameras.yaml'
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
[<ipython-input-5-935a973addd6>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('bash', '', 'python3 ./deep-image-matching/main.py \\\n  --dir ./deep-image-matching/assets/pytest \\\n  --pipeline sift+kornia_matcher \\\n  --skip_reconstruction\n')

4 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_shell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
    332     if line and not cell:
    333       cell = ' '
--> 334     return super().run_cell_magic(magic_name, line, cell)
    335 
    336 

[/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
   2471             with self.builtin_trap:
   2472                 args = (magic_arg_s, cell)
-> 2473                 result = fn(*args, **kwargs)
   2474             return result
   2475 

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    143 
    144         # write a basic docstring:

<decorator-gen-103> in shebang(self, line, cell)

[/usr/local/lib/python3.10/dist-packages/IPython/core/magic.py](https://localhost:8080/#) in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in shebang(self, line, cell)
    243             sys.stderr.flush()
    244         if args.raise_error and p.returncode!=0:
--> 245             raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
    246 
    247     def _run_script(self, p, cell, to_close):

CalledProcessError: Command 'b'python3 ./deep-image-matching/main.py \\\n  --dir ./deep-image-matching/assets/pytest \\\n  --pipeline sift+kornia_matcher \\\n  --skip_reconstruction\n'' returned non-zero exit status 1.

can you help me? thank you so much

lcmrl commented 3 months ago

Hi, thanks for the feedback, it is an issue with the path of camera config file. This should solve the issue:

%%bash
python3 ./deep-image-matching/main.py \
  --dir ./deep-image-matching/assets/pytest \
  --pipeline sift+kornia_matcher \
  --camera_options ./deep-image-matching/config/cameras.yaml \
  --skip_reconstruction \
  --force
pengxutao commented 3 months ago

thank you for your help. but when I run

# Pass to --images argument the names of the images (e.g. "img01.jpg img02.jpg") or their ids (e.g. "1 2") to visualize verified matches inside COLMAP database (change --type ['names', 'ids'])
%%bash
python3 ./deep-image-matching/show_matches.py \
  --images "1 2" \
  --type ids \
  --database ./deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/database.db \
  --imgsdir ./deep-image-matching/assets/pytest/images \
  --output ./deep-image-matching/assets/pytest/matches_sift+kornia_matcher.png \
  --max_size 500

here is an error too :

python3: can't open file '/content/./deep-image-matching/show_matches.py': [Errno 2] No such file or directory
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
[<ipython-input-6-73b51d8e4924>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('bash', '', 'python3 ./deep-image-matching/show_matches.py \\\n  --images "1 2" \\\n  --type ids \\\n  --database ./deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/database.db \\\n  --imgsdir ./deep-image-matching/assets/pytest/images \\\n  --output ./deep-image-matching/assets/pytest/matches_sift+kornia_matcher.png \\\n  --max_size 500\n')

4 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_shell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
    332     if line and not cell:
    333       cell = ' '
--> 334     return super().run_cell_magic(magic_name, line, cell)
    335 
    336 

[/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
   2471             with self.builtin_trap:
   2472                 args = (magic_arg_s, cell)
-> 2473                 result = fn(*args, **kwargs)
   2474             return result
   2475 

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    143 
    144         # write a basic docstring:

<decorator-gen-103> in shebang(self, line, cell)

[/usr/local/lib/python3.10/dist-packages/IPython/core/magic.py](https://localhost:8080/#) in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in shebang(self, line, cell)
    243             sys.stderr.flush()
    244         if args.raise_error and p.returncode!=0:
--> 245             raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
    246 
    247     def _run_script(self, p, cell, to_close):

CalledProcessError: Command 'b'python3 ./deep-image-matching/show_matches.py \\\n  --images "1 2" \\\n  --type ids \\\n  --database ./deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/database.db \\\n  --imgsdir ./deep-image-matching/assets/pytest/images \\\n  --output ./deep-image-matching/assets/pytest/matches_sift+kornia_matcher.png \\\n  --max_size 500\n'' returned non-zero exit status 2.
lcmrl commented 3 months ago

Use the --quality option instead of --max_size, for instance medium (here how it works https://3dom-fbk.github.io/deep-image-matching/getting_started/#quality)

image

pengxutao commented 3 months ago

The file notebooks/colab_run_from_bash_example.ipynb seems that it has not been updated in time, so it cannot run correctly on Colab. I will install and run DIM in my computer. Thank you for your help.