Prompt48 commited on
Commit
adadcb0
Β·
verified Β·
1 Parent(s): 607fd7c

Upload edit\Qwen3-TTS-test\.venv\Lib\site-packages\transformers\models\hgnet_v2\configuration_hgnet_v2.py with huggingface_hub

Browse files
edit//Qwen3-TTS-test//.venv//Lib//site-packages//transformers//models//hgnet_v2//configuration_hgnet_v2.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
2
+ # This file was automatically generated from src/transformers/models/hgnet_v2/modular_hgnet_v2.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_hgnet_v2.py file directly. One of our CI enforces this.
6
+ # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
7
+ # coding=utf-8
8
+ # Copyright 2025 Baidu Inc and The HuggingFace Inc. team.
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+
22
+
23
+ from ...configuration_utils import PretrainedConfig
24
+ from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
25
+
26
+
27
+ # TODO: Modular conversion for resnet must be fixed as
28
+ # it provides incorrect import for configuration like resnet_resnet
29
+ class HGNetV2Config(BackboneConfigMixin, PretrainedConfig):
30
+ """
31
+ This is the configuration class to store the configuration of a [`HGNetV2Backbone`]. It is used to instantiate a HGNet-V2
32
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
33
+ defaults will yield a similar configuration to that of D-FINE-X-COCO B4 "[ustc-community/dfine_x_coco"](https://huggingface.co/ustc-community/dfine_x_coco").
34
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
35
+ documentation from [`PretrainedConfig`] for more information.
36
+
37
+ Args:
38
+ num_channels (`int`, *optional*, defaults to 3):
39
+ The number of input channels.
40
+ embedding_size (`int`, *optional*, defaults to 64):
41
+ Dimensionality (hidden size) for the embedding layer.
42
+ depths (`list[int]`, *optional*, defaults to `[3, 4, 6, 3]`):
43
+ Depth (number of layers) for each stage.
44
+ hidden_sizes (`list[int]`, *optional*, defaults to `[256, 512, 1024, 2048]`):
45
+ Dimensionality (hidden size) at each stage.
46
+ hidden_act (`str`, *optional*, defaults to `"relu"`):
47
+ The non-linear activation function in each block. If string, `"gelu"`, `"relu"`, `"selu"` and `"gelu_new"`
48
+ are supported.
49
+ out_features (`list[str]`, *optional*):
50
+ If used as backbone, list of features to output. Can be any of `"stem"`, `"stage1"`, `"stage2"`, etc.
51
+ (depending on how many stages the model has). If unset and `out_indices` is set, will default to the
52
+ corresponding stages. If unset and `out_indices` is unset, will default to the last stage. Must be in the
53
+ same order as defined in the `stage_names` attribute.
54
+ out_indices (`list[int]`, *optional*):
55
+ If used as backbone, list of indices of features to output. Can be any of 0, 1, 2, etc. (depending on how
56
+ many stages the model has). If unset and `out_features` is set, will default to the corresponding stages.
57
+ If unset and `out_features` is unset, will default to the last stage. Must be in the
58
+ same order as defined in the `stage_names` attribute.
59
+ stem_channels (`list[int]`, *optional*, defaults to `[3, 32, 48]`):
60
+ Channel dimensions for the stem layers:
61
+ - First number (3) is input image channels
62
+ - Second number (32) is intermediate stem channels
63
+ - Third number (48) is output stem channels
64
+ stage_in_channels (`list[int]`, *optional*, defaults to `[48, 128, 512, 1024]`):
65
+ Input channel dimensions for each stage of the backbone.
66
+ This defines how many channels the input to each stage will have.
67
+ stage_mid_channels (`list[int]`, *optional*, defaults to `[48, 96, 192, 384]`):
68
+ Mid-channel dimensions for each stage of the backbone.
69
+ This defines the number of channels used in the intermediate layers of each stage.
70
+ stage_out_channels (`list[int]`, *optional*, defaults to `[128, 512, 1024, 2048]`):
71
+ Output channel dimensions for each stage of the backbone.
72
+ This defines how many channels the output of each stage will have.
73
+ stage_num_blocks (`list[int]`, *optional*, defaults to `[1, 1, 3, 1]`):
74
+ Number of blocks to be used in each stage of the backbone.
75
+ This controls the depth of each stage by specifying how many convolutional blocks to stack.
76
+ stage_downsample (`list[bool]`, *optional*, defaults to `[False, True, True, True]`):
77
+ Indicates whether to downsample the feature maps at each stage.
78
+ If `True`, the spatial dimensions of the feature maps will be reduced.
79
+ stage_light_block (`list[bool]`, *optional*, defaults to `[False, False, True, True]`):
80
+ Indicates whether to use light blocks in each stage.
81
+ Light blocks are a variant of convolutional blocks that may have fewer parameters.
82
+ stage_kernel_size (`list[int]`, *optional*, defaults to `[3, 3, 5, 5]`):
83
+ Kernel sizes for the convolutional layers in each stage.
84
+ stage_numb_of_layers (`list[int]`, *optional*, defaults to `[6, 6, 6, 6]`):
85
+ Number of layers to be used in each block of the stage.
86
+ use_learnable_affine_block (`bool`, *optional*, defaults to `False`):
87
+ Whether to use Learnable Affine Blocks (LAB) in the network.
88
+ LAB adds learnable scale and bias parameters after certain operations.
89
+ initializer_range (`float`, *optional*, defaults to 0.02):
90
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
91
+ """
92
+
93
+ model_type = "hgnet_v2"
94
+
95
+ def __init__(
96
+ self,
97
+ num_channels=3,
98
+ embedding_size=64,
99
+ depths=[3, 4, 6, 3],
100
+ hidden_sizes=[256, 512, 1024, 2048],
101
+ hidden_act="relu",
102
+ out_features=None,
103
+ out_indices=None,
104
+ stem_channels=[3, 32, 48],
105
+ stage_in_channels=[48, 128, 512, 1024],
106
+ stage_mid_channels=[48, 96, 192, 384],
107
+ stage_out_channels=[128, 512, 1024, 2048],
108
+ stage_num_blocks=[1, 1, 3, 1],
109
+ stage_downsample=[False, True, True, True],
110
+ stage_light_block=[False, False, True, True],
111
+ stage_kernel_size=[3, 3, 5, 5],
112
+ stage_numb_of_layers=[6, 6, 6, 6],
113
+ use_learnable_affine_block=False,
114
+ initializer_range=0.02,
115
+ **kwargs,
116
+ ):
117
+ super().__init__(**kwargs)
118
+ self.num_channels = num_channels
119
+ self.embedding_size = embedding_size
120
+ self.depths = depths
121
+ self.hidden_sizes = hidden_sizes
122
+ self.hidden_act = hidden_act
123
+ self.stage_names = ["stem"] + [f"stage{idx}" for idx in range(1, len(depths) + 1)]
124
+ self._out_features, self._out_indices = get_aligned_output_features_output_indices(
125
+ out_features=out_features, out_indices=out_indices, stage_names=self.stage_names
126
+ )
127
+ self.stem_channels = stem_channels
128
+ self.stage_in_channels = stage_in_channels
129
+ self.stage_mid_channels = stage_mid_channels
130
+ self.stage_out_channels = stage_out_channels
131
+ self.stage_num_blocks = stage_num_blocks
132
+ self.stage_downsample = stage_downsample
133
+ self.stage_light_block = stage_light_block
134
+ self.stage_kernel_size = stage_kernel_size
135
+ self.stage_numb_of_layers = stage_numb_of_layers
136
+ self.use_learnable_affine_block = use_learnable_affine_block
137
+ self.initializer_range = initializer_range
138
+
139
+ if not (
140
+ len(stage_in_channels)
141
+ == len(stage_mid_channels)
142
+ == len(stage_out_channels)
143
+ == len(stage_num_blocks)
144
+ == len(stage_downsample)
145
+ == len(stage_light_block)
146
+ == len(stage_kernel_size)
147
+ == len(stage_numb_of_layers)
148
+ ):
149
+ raise ValueError("All stage configuration lists must have the same length.")
150
+
151
+
152
+ __all__ = ["HGNetV2Config"]