alexstoken / image-matching-models

Code to easily try 30 (and growing) different image matching methods
https://earthloc-and-earthmatch.github.io/
BSD 3-Clause "New" or "Revised" License
262 stars 17 forks source link

Bug Report -- Unable to use multiple methods in the Matcher #15

Closed ZihanChen1995 closed 3 weeks ago

ZihanChen1995 commented 3 weeks ago

Hi, I am encountering a few bugs when loading the matchers in AWS SageMaker, The python version is Python 3.10.14, torch '2.4.0+cu118', and xformers '0.0.27.post2+cu118'.

Interestingly, these bugs do not show up in the Colab environment. Do you have any suggestions to resolve them? Thank you so much in advance!

First bug:

This occurs with the third_party library.

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/matching/third_party/imatch-toolbox/third_party/patch2pix/utils/eval/model_helper.py:6
      3 import numpy as np
      4 from argparse import Namespace
----> 6 from utils.common.setup_helper import load_weights
      7 from utils.datasets.preprocess import load_im_flexible, load_im_tensor
      8 from networks.patch2pix import Patch2Pix

ModuleNotFoundError: No module named 'utils.common'; 'utils' is not a package

Second bug:

This occurs when using orb-nn. When running correspondences = matcher(img1_resized, img2_resized), the following error appears:

FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/matching/third_party/accelerated_features/modules/../weights/xfeat.pt'

Third bug:

This occurs when using aspanformer. When the model is used for matching, it shows:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[83], line 1
----> 1 correspondences = matcher(img1_resized, img2_resized)

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/matching/im_models/base_matcher.py:217, in File ~/anaconda3/envs/python3/lib/python3.10/site-packages/matching/im_models/aspanformer.py:52, in AspanformerMatcher.preprocess(self, img)
     51 def preprocess(self, img):
---> 52     _, h, w = img.shape
     53     orig_shape = h, w
     54     img = resize_to_divisible(img, self.divisible_size)

ValueError: too many values to unpack (expected 3)
ZihanChen1995 commented 3 weeks ago

The bug has been resolved. The main cause was name conflicts with utils on the path. Avoiding such conflicts can prevent these issues.