configuration_pixio.py 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  2. # This file was automatically generated from src/transformers/models/pixio/modular_pixio.py.
  3. # Do NOT edit this file manually as any edits will be overwritten by the generation of
  4. # the file from the modular. If any change should be done, please apply the change to the
  5. # modular_pixio.py file directly. One of our CI enforces this.
  6. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  7. # Copyright 2025 Meta AI and The HuggingFace Inc. team. All rights reserved.
  8. #
  9. # Licensed under the Apache License, Version 2.0 (the "License");
  10. # you may not use this file except in compliance with the License.
  11. # You may obtain a copy of the License at
  12. #
  13. # http://www.apache.org/licenses/LICENSE-2.0
  14. #
  15. # Unless required by applicable law or agreed to in writing, software
  16. # distributed under the License is distributed on an "AS IS" BASIS,
  17. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. # See the License for the specific language governing permissions and
  19. # limitations under the License.
  20. from huggingface_hub.dataclasses import strict
  21. from ...backbone_utils import BackboneConfigMixin
  22. from ...configuration_utils import PreTrainedConfig
  23. from ...utils import auto_docstring
  24. @auto_docstring(checkpoint="facebook/pixio-huge")
  25. @strict
  26. class PixioConfig(BackboneConfigMixin, PreTrainedConfig):
  27. r"""
  28. apply_layernorm (`bool`, *optional*, defaults to `True`):
  29. Whether to apply layer normalization to the feature maps in case the model is used as backbone.
  30. reshape_hidden_states (`bool`, *optional*, defaults to `True`):
  31. Whether to reshape the feature maps to 4D tensors of shape `(batch_size, hidden_size, height, width)` in
  32. case the model is used as backbone. If `False`, the feature maps will be 3D tensors of shape `(batch_size,
  33. seq_len, hidden_size)`.
  34. n_cls_tokens (`int`, *optional*, defaults to 8):
  35. Number of class tokens in the Transformer encoder.
  36. Example:
  37. ```python
  38. >>> from transformers import PixioConfig, PixioModel
  39. >>> # Initializing a Pixio pixio-huge style configuration
  40. >>> configuration = PixioConfig()
  41. >>> # Initializing a model (with random weights) from the pixio-huge style configuration
  42. >>> model = PixioModel(configuration)
  43. >>> # Accessing the model configuration
  44. >>> configuration = model.config
  45. ```"""
  46. model_type = "pixio"
  47. hidden_size: int = 1280
  48. num_hidden_layers: int = 32
  49. num_attention_heads: int = 16
  50. mlp_ratio: int = 4
  51. hidden_act: str = "gelu"
  52. hidden_dropout_prob: float | int = 0.0
  53. attention_probs_dropout_prob: float | int = 0.0
  54. initializer_range: float = 0.02
  55. layer_norm_eps: float = 1e-6
  56. image_size: int | list[int] | tuple[int, int] = 256
  57. patch_size: int | list[int] | tuple[int, int] = 16
  58. num_channels: int = 3
  59. qkv_bias: bool = True
  60. drop_path_rate: float | int = 0.0
  61. _out_features: list[str] | None = None
  62. _out_indices: list[int] | None = None
  63. apply_layernorm: bool = True
  64. reshape_hidden_states: bool = True
  65. n_cls_tokens: int = 8
  66. def __post_init__(self, **kwargs):
  67. self.stage_names = ["stem"] + [f"stage{idx}" for idx in range(1, self.num_hidden_layers + 1)]
  68. self.set_output_features_output_indices(
  69. out_indices=kwargs.pop("out_indices", None), out_features=kwargs.pop("out_features", None)
  70. )
  71. super().__post_init__(**kwargs)
  72. __all__ = ["PixioConfig"]