configuration_superpoint.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright 2024 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from huggingface_hub.dataclasses import strict
  15. from ...configuration_utils import PreTrainedConfig
  16. from ...utils import auto_docstring
  17. @auto_docstring(checkpoint="magic-leap-community/superpoint")
  18. @strict
  19. class SuperPointConfig(PreTrainedConfig):
  20. r"""
  21. encoder_hidden_sizes (`List`, *optional*, defaults to `[64, 64, 128, 128]`):
  22. The number of channels in each convolutional layer in the encoder.
  23. keypoint_decoder_dim (`int`, *optional*, defaults to 65):
  24. The output dimension of the keypoint decoder.
  25. descriptor_decoder_dim (`int`, *optional*, defaults to 256):
  26. The output dimension of the descriptor decoder.
  27. keypoint_threshold (`float`, *optional*, defaults to 0.005):
  28. The threshold to use for extracting keypoints.
  29. max_keypoints (`int`, *optional*, defaults to -1):
  30. The maximum number of keypoints to extract. If `-1`, will extract all keypoints.
  31. nms_radius (`int`, *optional*, defaults to 4):
  32. The radius for non-maximum suppression.
  33. border_removal_distance (`int`, *optional*, defaults to 4):
  34. The distance from the border to remove keypoints.
  35. Example:
  36. ```python
  37. >>> from transformers import SuperPointConfig, SuperPointForKeypointDetection
  38. >>> # Initializing a SuperPoint superpoint style configuration
  39. >>> configuration = SuperPointConfig()
  40. >>> # Initializing a model from the superpoint style configuration
  41. >>> model = SuperPointForKeypointDetection(configuration)
  42. >>> # Accessing the model configuration
  43. >>> configuration = model.config
  44. ```"""
  45. model_type = "superpoint"
  46. encoder_hidden_sizes: list[int] | tuple[int, ...] = (64, 64, 128, 128)
  47. decoder_hidden_size: int = 256
  48. keypoint_decoder_dim: int = 65
  49. descriptor_decoder_dim: int = 256
  50. keypoint_threshold: float = 0.005
  51. max_keypoints: int = -1
  52. nms_radius: int = 4
  53. border_removal_distance: int = 4
  54. initializer_range: float = 0.02
  55. __all__ = ["SuperPointConfig"]