| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
- # This file was automatically generated from src/transformers/models/uvdoc/modular_uvdoc.py.
- # Do NOT edit this file manually as any edits will be overwritten by the generation of
- # the file from the modular. If any change should be done, please apply the change to the
- # modular_uvdoc.py file directly. One of our CI enforces this.
- # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
- # Copyright 2026 The PaddlePaddle Team and The HuggingFace Inc. team. All rights reserved.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- from collections.abc import Sequence
- from huggingface_hub.dataclasses import strict
- from ...backbone_utils import BackboneConfigMixin, consolidate_backbone_kwargs_to_config
- from ...configuration_utils import PreTrainedConfig
- from ...utils import auto_docstring
- from ..auto import AutoConfig
- @auto_docstring(checkpoint="PaddlePaddle/UVDoc_safetensors")
- @strict
- class UVDocBackboneConfig(BackboneConfigMixin, PreTrainedConfig):
- r"""
- resnet_head (`Sequence[list[int] | tuple[int, ...]]`, *optional*, defaults to `((3, 32), (32, 32))`):
- Configuration for the ResNet head layers in format [in_channels, out_channels].
- resnet_configs (`Sequence[Sequence[tuple[int, int, int, bool] | list[int | bool]]]`, *optional*, defaults to `(((32, 32, 1, False),
- (32, 32, 3, False), (32, 32, 3, False)), ((32, 64, 1, True), (64, 64, 3, False), (64, 64, 3, False), (64, 64, 3, False)), ((64, 128, 1, True),
- (128, 128, 3, False), (128, 128, 3, False), (128, 128, 3, False), (128, 128, 3, False), (128, 128, 3, False)))`):
- Configuration for the ResNet stages in format [in_channels, out_channels, dilation_value, downsample].
- stage_configs (Sequence[Sequence[tuple[int, ...] | list[int]]], *optional*, defaults to `(((128, 1),), ((128, 2),),
- ((128, 5),), ((128, 8),(128, 3),(128, 2),), ((128, 12), (128, 7), (128, 4),), ((128, 18), (128, 12), (128, 6),),)`):
- Configuration for the bridge module stages in format [in_channels, dilation_value].
- Each inner sequence corresponds to a single bridge block, and the outer sequence groups blocks by bridge stage.
- """
- model_type = "uvdoc_backbone"
- _out_features: list[str] | None = None
- _out_indices: list[int] | None = None
- resnet_head: Sequence[list[int] | tuple[int, ...]] = (
- (3, 32),
- (32, 32),
- )
- resnet_configs: Sequence[Sequence[tuple[int, int, int, bool] | list[int | bool]]] = (
- (
- (32, 32, 1, False),
- (32, 32, 3, False),
- (32, 32, 3, False),
- ),
- (
- (32, 64, 1, True),
- (64, 64, 3, False),
- (64, 64, 3, False),
- (64, 64, 3, False),
- ),
- (
- (64, 128, 1, True),
- (128, 128, 3, False),
- (128, 128, 3, False),
- (128, 128, 3, False),
- (128, 128, 3, False),
- (128, 128, 3, False),
- ),
- )
- stage_configs: Sequence[Sequence[tuple[int, ...] | list[int]]] = (
- ((128, 1),),
- ((128, 2),),
- ((128, 5),),
- (
- (128, 8),
- (128, 3),
- (128, 2),
- ),
- (
- (128, 12),
- (128, 7),
- (128, 4),
- ),
- (
- (128, 18),
- (128, 12),
- (128, 6),
- ),
- )
- kernel_size: int = 5
- def __post_init__(self, **kwargs):
- self.depths = [len(stages) for stages in self.stage_configs]
- self.stage_names = ["stem"] + [f"stage{idx}" for idx in range(1, len(self.stage_configs) + 1)]
- self.set_output_features_output_indices(
- out_indices=kwargs.pop("out_indices", None), out_features=kwargs.pop("out_features", None)
- )
- super().__post_init__(**kwargs)
- @auto_docstring(checkpoint="PaddlePaddle/UVDoc_safetensors")
- @strict
- class UVDocConfig(PreTrainedConfig):
- r"""
- padding_mode (`str`, *optional*, defaults to `"reflect"`):
- Padding mode for convolutional layers. Supported modes are `"reflect"`, `"constant"`, and `"replicate"`.
- kernel_size (`int`, *optional*, defaults to 5):
- Kernel size for convolutional layers in the backbone network.
- bridge_connector (`list[int] | tuple[int, ...]`, *optional*, defaults to `(128, 128)`):
- Configuration for the bridge connector in format [in_channels, out_channels].
- out_point_positions2D (`Sequence[list[int] | tuple[int, ...]]`, *optional*, defaults to `((128, 32), (32, 2))`):
- Configuration for the output point positions 2D layer in format [in_channels, out_channels].
- """
- model_type = "uvdoc"
- sub_configs = {"backbone_config": AutoConfig}
- backbone_config: dict | PreTrainedConfig | None = None
- hidden_act: str = "prelu"
- padding_mode: str = "reflect"
- kernel_size: int = 5
- bridge_connector: list[int] | tuple[int, ...] = (128, 128)
- out_point_positions2D: Sequence[list[int] | tuple[int, ...]] = ((128, 32), (32, 2))
- def __post_init__(self, **kwargs):
- self.backbone_config, kwargs = consolidate_backbone_kwargs_to_config(
- backbone_config=self.backbone_config,
- default_config_type="uvdoc_backbone",
- **kwargs,
- )
- super().__post_init__(**kwargs)
- __all__ = ["UVDocBackboneConfig", "UVDocConfig"]
|