#                🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
#           This file was automatically generated from src/transformers/models/pp_ocrv5_server_det/modular_pp_ocrv5_server_det.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_ocrv5_server_det.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 consolidate_backbone_kwargs_to_config
from ...configuration_utils import PreTrainedConfig
from ...utils import auto_docstring
from ..auto import AutoConfig


@auto_docstring(checkpoint="PaddlePaddle/PP-OCRv5_server_det_safetensors")
@strict
class PPOCRV5ServerDetConfig(PreTrainedConfig):
    r"""
    interpolate_mode (`str`, *optional*, defaults to `"nearest"`):
        The interpolation mode used for upsampling or downsampling feature maps in the neck network.
    neck_out_channels (`int`, *optional*, defaults to 256):
        The number of output channels from the neck network, responsible for feature fusion and refinement.
    reduce_factor (`int`, *optional*, defaults to 2):
        The channel reduction factor used in the neck blocks to balance performance and complexity.
    intraclass_block_number (`int`, *optional*, defaults to 4):
        The number of Intra-Class Block modules used for enhancing feature representation.
    intraclass_block_config (`dict`, *optional*, defaults to `None`):
        Configuration for the Intra-Class Block modules, if any, used for enhancing feature representation.
    scale_factor (`int`, *optional*, defaults to 2):
        The scaling factor used for spatial resolution adjustments in the feature maps.
    scale_factor_list (`list[int]`, *optional*, defaults to `None`):
        A list of scaling factors used for spatial resolution adjustments in the feature maps.
    kernel_list (`list[int]`, *optional*, defaults to `[3, 2, 2]`):
        The list of kernel sizes for convolutional layers in the head network for multi-scale feature extraction.
    """

    sub_configs = {"backbone_config": AutoConfig}
    model_type = "pp_ocrv5_server_det"

    interpolate_mode: str = "nearest"
    backbone_config: dict | PreTrainedConfig | None = None
    neck_out_channels: int = 256
    reduce_factor: int = 2
    intraclass_block_number: int = 4
    intraclass_block_config: dict | None = None
    scale_factor: int = 2
    scale_factor_list: list | None = None
    hidden_act: str = "relu"
    kernel_list: list | None = None
    id2label: dict[int, str] | dict[str, str] | None = None

    def __post_init__(self, **kwargs):
        self.backbone_config, kwargs = consolidate_backbone_kwargs_to_config(
            backbone_config=self.backbone_config,
            default_config_type="hgnet_v2",
            default_config_kwargs={
                "arch": "L",
                "return_idx": [0, 1, 2, 3],
                "freeze_stem_only": True,
                "freeze_at": 0,
                "freeze_norm": True,
                "lr_mult_list": [0, 0.05, 0.05, 0.05, 0.05],
                "out_features": ["stage1", "stage2", "stage3", "stage4"],
            },
            **kwargs,
        )

        # For object detection pipeline compatibility: single class "text"
        self.id2label = {0: "text"} if self.id2label is None else self.id2label
        super().__post_init__(**kwargs)


__all__ = ["PPOCRV5ServerDetConfig"]
