CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
configuration_dinov3_convnext.py104 linesDownload Raw Back to dinov3_convnext
1# coding=utf-82# Copyright 2025 Meta Platforms, Inc. and The HuggingFace Inc. team. All rights reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8#     http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""ConvNeXT model configuration"""16 17from typing import Optional18 19from ...configuration_utils import PretrainedConfig20from ...utils import logging21 22 23logger = logging.get_logger(__name__)24 25 26class DINOv3ConvNextConfig(PretrainedConfig):27    r"""28    This is the configuration class to store the configuration of a [`DINOv3ConvNextModel`]. It is used to instantiate an29    DINOv3ConvNext model according to the specified arguments, defining the model architecture. Instantiating a configuration30    with the defaults will yield a similar configuration to that of the DINOv3ConvNext31    [facebook/dinov3-convnext-tiny-pretrain-lvd1689m](https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m) architecture.32 33    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the34    documentation from [`PretrainedConfig`] for more information.35 36    Args:37        num_channels (`int`, *optional*, defaults to 3):38            The number of input channels.39        hidden_sizes (`list[int]`, *optional*, defaults to [96, 192, 384, 768]):40            Dimensionality (hidden size) at each stage.41        depths (`list[int]`, *optional*, defaults to [3, 3, 9, 3]):42            The number of layers for each stage.43        hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):44            The non-linear activation function (function or string) in each block. If string, `"gelu"`, `"relu"`,45            `"selu"` and `"gelu_new"` are supported.46        initializer_range (`float`, *optional*, defaults to 0.02):47            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.48        layer_norm_eps (`float`, *optional*, defaults to 1e-06):49            The epsilon used by the layer normalization layers.50        layer_scale_init_value (`float`, *optional*, defaults to 1e-06):51            The initial value for the layer scale.52        drop_path_rate (`float`, *optional*, defaults to 0.0):53            The drop rate for stochastic depth.54        image_size (`int`, *optional*, defaults to 224):55            The size (resolution) of input images.56 57    Example:58    ```python59    >>> from transformers import DINOv3ConvNextConfig, DINOv3ConvNextModel60 61    >>> # Initializing a DINOv3ConvNext (tiny variant) style configuration62    >>> config = DINOv3ConvNextConfig()63 64    >>> # Initializing a model (with random weights)65    >>> model = DINOv3ConvNextModel(config)66 67    >>> # Accessing the model config68    >>> config = model.config69    ```"""70 71    model_type = "dinov3_convnext"72 73    def __init__(74        self,75        num_channels: int = 3,76        hidden_sizes: Optional[list[int]] = None,77        depths: Optional[list[int]] = None,78        hidden_act: str = "gelu",79        initializer_range: float = 0.02,80        layer_norm_eps: float = 1e-6,81        layer_scale_init_value: float = 1e-6,82        drop_path_rate: float = 0.0,83        image_size: int = 224,84        **kwargs,85    ):86        super().__init__(**kwargs)87 88        self.num_channels = num_channels89        self.hidden_sizes = [96, 192, 384, 768] if hidden_sizes is None else hidden_sizes90        self.depths = [3, 3, 9, 3] if depths is None else depths91        self.hidden_act = hidden_act92        self.initializer_range = initializer_range93        self.layer_norm_eps = layer_norm_eps94        self.layer_scale_init_value = layer_scale_init_value95        self.drop_path_rate = drop_path_rate96        self.image_size = image_size97 98    @property99    def num_stages(self) -> int:100        return len(self.hidden_sizes)101 102 103__all__ = ["DINOv3ConvNextConfig"]104 
Aluode/PerceptionLabPortable · CoolFace