Conversation
src/super_point.py
Outdated
| raw_kp = processed['keypoints'].cpu().numpy() | ||
| raw_scores = processed['scores'].cpu().numpy() | ||
| raw_des = processed['descriptors'].cpu().numpy().astype(np.float32) |
There was a problem hiding this comment.
Вот здесь тонкий момент: возможно в какой-то момент захочется запускать инференс этих моделей на GPU, поэтому нужно будет сделать внешний параметр cpu или gpu, чтобы корректно управлять тензорами
src/super_point.py
Outdated
| def detect(self, img): | ||
| return self._forward(img)[0] | ||
|
|
||
| def compute(self, img, kp): | ||
| model_kp, model_des = self._forward(img) |
There was a problem hiding this comment.
Вроде обговаривали, что мы не инферим модель 2 раза. Мы проход по сетке делаем один раз и сохраняем результат в переменную, потом просто этот результат возвращаем (detect инферит, а compute возвращает ранее посчитанные дескрипторы). Только нужно будет подумать как создавать один и тот же экземпляр класса в 2 разных переменных
…f separate kp/des
| @pytest.fixture | ||
| def load_img(): | ||
| def _load(name, color=True): | ||
| path = Path(__file__).parent.parent / "test_data" / name |
There was a problem hiding this comment.
Здесь надо использовать os.path.join(...) для склеивания путей.
src/matchers.py
Outdated
|
|
||
| @abstractmethod | ||
| def _simple_match(self, des1, des2): | ||
| def match(self, **kwargs): |
There was a problem hiding this comment.
Вместо **kwargs передаем словарь.
src/matchers.py
Outdated
| super().__init__(logger, matcher_name, descriptor_name) | ||
| self.mode = mode | ||
|
|
||
| def match(self, **kwargs): |
There was a problem hiding this comment.
Здесь тоже словарь типа {'des1': ..., 'des2': ...}
src/matchers.py
Outdated
| bf = self._init_matcher() | ||
| return bf.match(des1, des2) | ||
| class BFMatcher(OpenCVMatcher): | ||
| def __init__(self, logger, matcher_name, descriptor_name, **kwargs): |
There was a problem hiding this comment.
Вместо **kwargs используем словарь
src/matchers.py
Outdated
| def __init__(self, logger, descriptor_method, mode='simple', **kwargs): | ||
| super().__init__(logger, descriptor_method, mode, **kwargs) | ||
| class FLANNMatcher(OpenCVMatcher): | ||
| def __init__(self, logger, matcher_name, descriptor_name, **kwargs): |
src/light_glue.py
Outdated
| LightGlueMatcher._shared_matchers[matcher_key] = (LightGlue(features=self.extractor_type) | ||
| .eval().to(self._device)) |
There was a problem hiding this comment.
Создать только один объект LightGlue
src/light_glue.py
Outdated
| self._device = torch.device(device) | ||
| self.extractor_type = extractor_type.lower() | ||
|
|
||
| matcher_key = (self.extractor_type, self._device.type) |
src/light_glue.py
Outdated
| matches01 = self._matcher(input_dict) | ||
| matches01 = rbd(matches01) | ||
|
|
||
| return matches01["matches"] No newline at end of file |
There was a problem hiding this comment.
Нужно вернуть достоверности для соответствий
src/super_point.py
Outdated
| kp = [cv.KeyPoint(x=float(p[0]), y=float(p[1]), size=8, response=float(s)) | ||
| for p, s in zip(raw_kp[mask], raw_scores[mask])] | ||
| des = raw_des[mask] |
There was a problem hiding this comment.
Вынести в отдельную функцию/класс PostProcessor в скрипт auxiliary.py перевод точек в формат cv.KeyPoint
src/super_point.py
Outdated
|
|
||
| def compute(self, img, features): | ||
| kp, des = self._forward(img) | ||
| return {'kp': kp, 'des': des} |
There was a problem hiding this comment.
Аналогично ввести флаг состояния
|
@ismukhin Исправили код, все тесты проходят, позапускали все алгоритмы, все работает. |
samples/match_cv.py
Outdated
|
|
||
|
|
||
| def build_detector_config(args): | ||
| config = {} |
samples/match_cv.py
Outdated
|
|
||
|
|
||
| def build_descriptor_config(args): | ||
| config = {} |
samples/match_cv.py
Outdated
|
|
||
|
|
||
| def build_matcher_config(args): | ||
| config = {} |
samples/match_cv.py
Outdated
|
|
||
|
|
||
| def build_preprocessor_config(args): | ||
| config = {} |
samples/match_cv.py
Outdated
| def build_preprocessor_config(args): | ||
| config = {} | ||
| if args.pre_device is not None: | ||
| config['device'] = args.pre_device |
There was a problem hiding this comment.
Непонятно зачем здесь device, нужно гарантировать, что все операции выполняются на одном устройстве
| @@ -0,0 +1,85 @@ | |||
| import cv2 as cv | |||
src/preprocessor.py
Outdated
| if algo in self._VALID_FORMATS: | ||
| return algo | ||
|
|
||
| if algo in NEURAL_ALGORITHMS: |
src/preprocessor.py
Outdated
| from src.converter import Converter | ||
|
|
||
|
|
||
| class PreProcessor: |
src/super_point.py
Outdated
| else: | ||
| self._device = torch.device(device) | ||
|
|
||
| if SuperPoint._shared_model is None: |
src/super_point.py
Outdated
| self._device = torch.device(device) | ||
|
|
||
| if SuperPoint._shared_model is None: | ||
| SuperPoint._shared_processor = AutoImageProcessor.from_pretrained( |
There was a problem hiding this comment.
SuperPoint._image_processor
No description provided.