# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 # This file was automatically generated from src/transformers/models/pp_lcnet/modular_pp_lcnet.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_pp_lcnet.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 huggingface_hub.dataclasses import strict from ...backbone_utils import BackboneConfigMixin from ...configuration_utils import PreTrainedConfig from ...utils import auto_docstring @auto_docstring(checkpoint="PaddlePaddle/PP-LCNet_x1_0_doc_ori_safetensors") @strict class PPLCNetConfig(BackboneConfigMixin, PreTrainedConfig): r""" scale (`float`, *optional*, defaults to 1.0): The scaling factor for the model's channel dimensions, used to adjust the model size and computational cost without changing the overall architecture (e.g., 0.25, 0.5, 1.0, 1.5). block_configs (`list[list[tuple]]`, *optional*, defaults to `None`): Configuration for each block in each stage. Each tuple contains: (kernel_size, in_channels, out_channels, stride, use_squeeze_excitation). If `None`, uses the default PP-LCNet configuration. stem_channels (`int`, *optional*, defaults to 16): The number of output channels for the stem layer. stem_stride (`int`, *optional*, defaults to 2): The stride for the stem convolution layer. reduction (`int`, *optional*, defaults to 4): The reduction factor for feature channel dimensions in the squeeze-and-excitation (SE) blocks, used to reduce the number of model parameters and computational complexity while maintaining feature representability. class_expand (`int`, *optional*, defaults to 1280): The number of hidden units in the expansion layer of the classification head, used to enhance the model's feature representation capability before the final classification layer. divisor (`int`, *optional*, defaults to 8): The divisor used to ensure that various model parameters (e.g., channel dimensions, kernel sizes) are multiples of this value, promoting efficient model implementation and resource utilization. """ model_type = "pp_lcnet" scale: float | int = 1.0 block_configs: list | None = None stem_channels: int = 16 stem_stride: int = 2 reduction: int = 4 class_expand: int = 1280 divisor: int = 8 hidden_act: str = "hardswish" _out_features: list[str] | None = None _out_indices: list[int] | None = None hidden_dropout_prob: float | int = 0.2 def __post_init__(self, **kwargs): # Default block configs for PP-LCNet # Each tuple: (kernel_size, in_channels, out_channels, stride, use_squeeze_excitation) self.block_configs = ( [ # Stage 1 (blocks2) [[3, 16, 32, 1, False]], # Stage 2 (blocks3) [[3, 32, 64, 2, False], [3, 64, 64, 1, False]], # Stage 3 (blocks4) [[3, 64, 128, 2, False], [3, 128, 128, 1, False]], # Stage 4 (blocks5) [ [3, 128, 256, 2, False], [5, 256, 256, 1, False], [5, 256, 256, 1, False], [5, 256, 256, 1, False], [5, 256, 256, 1, False], [5, 256, 256, 1, False], ], # Stage 5 (blocks6) [[5, 256, 512, 2, True], [5, 512, 512, 1, True]], ] if self.block_configs is None else self.block_configs ) self.depths = [len(blocks) for blocks in self.block_configs] self.stage_names = ["stem"] + [f"stage{idx}" for idx in range(1, len(self.block_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) def validate_architecture(self): """Part of `@strict`-powered validation. Validates the architecture of the config.""" if len(self.block_configs) != 5: raise ValueError(f"block_configs must have 5 stages, but got {len(self.block_configs)}") __all__ = ["PPLCNetConfig"]