configuration_yolos.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 2022 The HuggingFace Inc. 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. """YOLOS model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="hustvl/yolos-base")
  19. @strict
  20. class YolosConfig(PreTrainedConfig):
  21. r"""
  22. num_detection_tokens (`int`, *optional*, defaults to 100):
  23. The number of detection tokens.
  24. use_mid_position_embeddings (`bool`, *optional*, defaults to `True`):
  25. Whether to use the mid-layer position encodings.
  26. Example:
  27. ```python
  28. >>> from transformers import YolosConfig, YolosModel
  29. >>> # Initializing a YOLOS hustvl/yolos-base style configuration
  30. >>> configuration = YolosConfig()
  31. >>> # Initializing a model (with random weights) from the hustvl/yolos-base style configuration
  32. >>> model = YolosModel(configuration)
  33. >>> # Accessing the model configuration
  34. >>> configuration = model.config
  35. ```"""
  36. model_type = "yolos"
  37. hidden_size: int = 768
  38. num_hidden_layers: int = 12
  39. num_attention_heads: int = 12
  40. intermediate_size: int = 3072
  41. hidden_act: str = "gelu"
  42. hidden_dropout_prob: float | int = 0.0
  43. attention_probs_dropout_prob: float | int = 0.0
  44. initializer_range: float = 0.02
  45. layer_norm_eps: float = 1e-12
  46. image_size: list[int] | tuple[int, ...] = (512, 864)
  47. patch_size: int | list[int] | tuple[int, int] = 16
  48. num_channels: int = 3
  49. qkv_bias: bool = True
  50. num_detection_tokens: int = 100
  51. use_mid_position_embeddings: bool = True
  52. auxiliary_loss: bool = False
  53. class_cost: int = 1
  54. bbox_cost: int = 5
  55. giou_cost: int = 2
  56. bbox_loss_coefficient: int = 5
  57. giou_loss_coefficient: int = 2
  58. eos_coefficient: float = 0.1
  59. __all__ = ["YolosConfig"]