Ë
    S^(hÚM  ã                   ó¼  — d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ dd	lmZmZmZmZ d
dlmZ d
dlmZmZmZmZ  ej<                  e«      Z  eg d¢«      Z! eee!«      Z"de#fd„Z$	 	 	 	 	 	 	 dde
e#ejJ                  f   de	e
e#ejJ                  f      de&de	e&   de	ee#e#f      de	e
e&e#f      de	e#   de&fd„Z' G d„ d«      Z(y)zAutoFeatureExtractor class.é    N)ÚOrderedDict)ÚDictÚOptionalÚUnioné   )ÚPretrainedConfig)Úget_class_from_dynamic_moduleÚresolve_trust_remote_code)ÚFeatureExtractionMixin)ÚCONFIG_NAMEÚFEATURE_EXTRACTOR_NAMEÚcached_fileÚloggingé   )Ú_LazyAutoMapping)ÚCONFIG_MAPPING_NAMESÚ
AutoConfigÚmodel_type_to_module_nameÚ!replace_list_option_in_docstrings)I)zaudio-spectrogram-transformerÚASTFeatureExtractor)ÚbeitÚBeitFeatureExtractor)Úchinese_clipÚChineseCLIPFeatureExtractor)ÚclapÚClapFeatureExtractor)ÚclipÚCLIPFeatureExtractor)ÚclipsegÚViTFeatureExtractor)ÚclvpÚClvpFeatureExtractor)Úconditional_detrÚConditionalDetrFeatureExtractor)ÚconvnextÚConvNextFeatureExtractor)Úcvtr&   )ÚdacÚDacFeatureExtractor)zdata2vec-audioÚWav2Vec2FeatureExtractor)zdata2vec-visionr   )Údeformable_detrÚDeformableDetrFeatureExtractor)ÚdeitÚDeiTFeatureExtractor)ÚdetrÚDetrFeatureExtractor)Údinatr    )z
donut-swinÚDonutFeatureExtractor)ÚdptÚDPTFeatureExtractor)ÚencodecÚEncodecFeatureExtractor)ÚflavaÚFlavaFeatureExtractor)ÚglpnÚGLPNFeatureExtractor)Úgroupvitr   )Úhubertr*   )ÚimagegptÚImageGPTFeatureExtractor)Ú
layoutlmv2ÚLayoutLMv2FeatureExtractor)Ú
layoutlmv3ÚLayoutLMv3FeatureExtractor)ÚlevitÚLevitFeatureExtractor)Ú
maskformerÚMaskFormerFeatureExtractor)ÚmctctÚMCTCTFeatureExtractor)Úmimir6   )Úmobilenet_v1ÚMobileNetV1FeatureExtractor)Úmobilenet_v2ÚMobileNetV2FeatureExtractor)Ú	mobilevitÚMobileViTFeatureExtractor)Ú	moonshiner*   )Úmoshir6   )Únatr    )ÚowlvitÚOwlViTFeatureExtractor)Ú	perceiverÚPerceiverFeatureExtractor)Úphi4_multimodalÚPhi4MultimodalFeatureExtractor)Ú
poolformerÚPoolFormerFeatureExtractor)Ú	pop2pianoÚPop2PianoFeatureExtractor)Úregnetr&   )Úresnetr&   )Úseamless_m4tÚSeamlessM4TFeatureExtractor)Úseamless_m4t_v2r`   )Ú	segformerÚSegformerFeatureExtractor)Úsewr*   )zsew-dr*   )Úspeech_to_textÚSpeech2TextFeatureExtractor)Úspeecht5ÚSpeechT5FeatureExtractor)Úswiftformerr    )Úswinr    )Úswinv2r    )ztable-transformerr0   )ÚtimesformerÚVideoMAEFeatureExtractor)ÚtvltÚTvltFeatureExtractor)Ú	unispeechr*   )zunispeech-satr*   )ÚunivnetÚUnivNetFeatureExtractor)Úvanr&   )Úvideomaerm   )ÚviltÚViltFeatureExtractor)Úvitr    )Úvit_maer    )Úvit_msnr    )Úwav2vec2r*   )zwav2vec2-bertr*   )zwav2vec2-conformerr*   )Úwavlmr*   )ÚwhisperÚWhisperFeatureExtractor)Úxclipr   )ÚyolosÚYolosFeatureExtractorÚ
class_namec                 ó–  — t         j                  «       D ]<  \  }}| |v sŒt        |«      }t        j                  d|› �d«      }	 t        || «      c S  t        j                  j                  «       D ]  \  }}t        |dd «      | k(  sŒ|c S  t        j                  d«      }t        || «      rt        || «      S y # t        $ r Y Œ²w xY w)Nú.ztransformers.modelsÚ__name__Útransformers)
ÚFEATURE_EXTRACTOR_MAPPING_NAMESÚitemsr   Ú	importlibÚimport_moduleÚgetattrÚAttributeErrorÚFEATURE_EXTRACTOR_MAPPINGÚ_extra_contentÚhasattr)r�   Úmodule_nameÚ
extractorsÚmoduleÚ_Ú	extractorÚmain_modules          ún/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/auto/feature_extraction_auto.pyÚ!feature_extractor_class_from_namer–   y   sØ   € Ü#B×#HÑ#HÓ#Jò Ñˆ�ZØ˜Ò#Ü3°KÓ@ˆKä×,Ñ,¨q°°Ð->Ð@UÓVˆFðÜ˜v zÓ2Ò2ðô 2×@Ñ@×FÑFÓHò ‰ˆˆ9Ü�9˜j¨$Ó/°:Ó=ØÒðô ×)Ñ)¨.Ó9€KÜˆ{˜JÔ'Ü�{ JÓ/Ð/àøô "ò Ùðús   ÁB<Â<	CÃCÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚresume_downloadÚproxiesÚtokenÚrevisionÚlocal_files_onlyc                 óT  — |j                  dd«      }	|	�)t        j                  dt        «       |�t	        d«      ‚|	}t        | t        |||||||ddd¬«      }
|
€t        j                  d«       i S t        |
d¬	«      5 }t        j                  |«      cddd«       S # 1 sw Y   yxY w)
a2  
    Loads the tokenizer configuration from a pretrained model tokenizer configuration.

    Args:
        pretrained_model_name_or_path (`str` or `os.PathLike`):
            This can be either:

            - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
              huggingface.co.
            - a path to a *directory* containing a configuration file saved using the
              [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`.

        cache_dir (`str` or `os.PathLike`, *optional*):
            Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
            cache should not be used.
        force_download (`bool`, *optional*, defaults to `False`):
            Whether or not to force to (re-)download the configuration files and override the cached versions if they
            exist.
        resume_download:
            Deprecated and ignored. All downloads are now resumed by default when possible.
            Will be removed in v5 of Transformers.
        proxies (`Dict[str, str]`, *optional*):
            A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
            'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
        token (`str` or *bool*, *optional*):
            The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
            when running `huggingface-cli login` (stored in `~/.huggingface`).
        revision (`str`, *optional*, defaults to `"main"`):
            The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
            git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
            identifier allowed by git.
        local_files_only (`bool`, *optional*, defaults to `False`):
            If `True`, will only try to load the tokenizer configuration from local files.

    <Tip>

    Passing `token=True` is required when you want to use a private model.

    </Tip>

    Returns:
        `Dict`: The configuration of the tokenizer.

    Examples:

    ```python
    # Download configuration from huggingface.co and cache.
    tokenizer_config = get_tokenizer_config("google-bert/bert-base-uncased")
    # This model does not have a tokenizer config so the result will be an empty dict.
    tokenizer_config = get_tokenizer_config("FacebookAI/xlm-roberta-base")

    # Save a pretrained tokenizer locally and you can reload its config
    from transformers import AutoTokenizer

    tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-cased")
    tokenizer.save_pretrained("tokenizer-test")
    tokenizer_config = get_tokenizer_config("tokenizer-test")
    ```Úuse_auth_tokenNúrThe `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.úV`token` and `use_auth_token` are both specified. Please set only the argument `token`.F)
r˜   r™   rš   r›   rœ   r�   rž   Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesÚ'_raise_exceptions_for_connection_errorszdCould not locate the feature extractor configuration file, will try to use the model config instead.zutf-8)Úencoding)ÚpopÚwarningsÚwarnÚFutureWarningÚ
ValueErrorr   r   ÚloggerÚinfoÚopenÚjsonÚload)r—   r˜   r™   rš   r›   rœ   r�   rž   Úkwargsr    Úresolved_config_fileÚreaders               r•   Úget_feature_extractor_configr´   ‘   sÅ   € ðJ —Z‘ZÐ 0°$Ó7€NØÐ!Ü�‰ð AÜô	
ð ÐÜÐuÓvÐvØˆä&Ø%ÜØØ%Ø'ØØØØ)Ø).Ø.3Ø05ôÐð Ð#Ü�‰Ørô	
ð ˆ	ä	Ð"¨WÔ	5ð !¸Ü�y‰y˜Ó ÷!÷ !ò !ús   Á?BÂB'c                   óN   — e Zd ZdZd„ Ze ee«      d„ «       «       Ze	dd„«       Z
y)ÚAutoFeatureExtractora+  
    This is a generic feature extractor class that will be instantiated as one of the feature extractor classes of the
    library when created with the [`AutoFeatureExtractor.from_pretrained`] class method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
    c                 ó   — t        d«      ‚)Nz‹AutoFeatureExtractor is designed to be instantiated using the `AutoFeatureExtractor.from_pretrained(pretrained_model_name_or_path)` method.)ÚEnvironmentError)Úselfs    r•   Ú__init__zAutoFeatureExtractor.__init__   s   € Üðfó
ð 	
ó    c                 ó²  — |j                  dd«      }|�<t        j                  dt        «       |j	                  dd«      �t        d«      ‚||d<   |j                  dd«      }|j                  dd«      }d|d	<   t        j                  |fi |¤Ž\  }}|j	                  d
d«      }d}	d|j	                  di «      v r|d   d   }	|€`|	€^t        |t        «      st        j                  |fd|i|¤Ž}t        |d
d«      }t        |d«      rd|j                  v r|j                  d   }	|�t        |«      }|	du}
|duxs t!        |«      t"        v }t%        ||||
«      }|
rc|rat'        |	|fi |¤Ž}|j                  dd«      }t(        j*                  j-                  |«      r|j/                  «         |j0                  |fi |¤ŽS |� |j0                  |fi |¤ŽS t!        |«      t"        v r%t"        t!        |«         } |j0                  |fi |¤ŽS t        d|› dt2        › dt4        › dt4        › ddj7                  d„ t8        j;                  «       D «       «      › �
«      ‚)a…  
        Instantiate one of the feature extractor classes of the library from a pretrained model vocabulary.

        The feature extractor class to instantiate is selected based on the `model_type` property of the config object
        (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it's
        missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:

        List options

        Params:
            pretrained_model_name_or_path (`str` or `os.PathLike`):
                This can be either:

                - a string, the *model id* of a pretrained feature_extractor hosted inside a model repo on
                  huggingface.co.
                - a path to a *directory* containing a feature extractor file saved using the
                  [`~feature_extraction_utils.FeatureExtractionMixin.save_pretrained`] method, e.g.,
                  `./my_model_directory/`.
                - a path or url to a saved feature extractor JSON *file*, e.g.,
                  `./my_model_directory/preprocessor_config.json`.
            cache_dir (`str` or `os.PathLike`, *optional*):
                Path to a directory in which a downloaded pretrained model feature extractor should be cached if the
                standard cache should not be used.
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force to (re-)download the feature extractor files and override the cached versions
                if they exist.
            resume_download:
                Deprecated and ignored. All downloads are now resumed by default when possible.
                Will be removed in v5 of Transformers.
            proxies (`Dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
                when running `huggingface-cli login` (stored in `~/.huggingface`).
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
                git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
                identifier allowed by git.
            return_unused_kwargs (`bool`, *optional*, defaults to `False`):
                If `False`, then this function returns just the final feature extractor object. If `True`, then this
                functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a dictionary
                consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the part of
                `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored.
            trust_remote_code (`bool`, *optional*, defaults to `False`):
                Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
                should only be set to `True` for repositories you trust and in which you have read the code, as it will
                execute code present on the Hub on your local machine.
            kwargs (`Dict[str, Any]`, *optional*):
                The values in kwargs of any keys which are feature extractor attributes will be used to override the
                loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is
                controlled by the `return_unused_kwargs` keyword parameter.

        <Tip>

        Passing `token=True` is required when you want to use a private model.

        </Tip>

        Examples:

        ```python
        >>> from transformers import AutoFeatureExtractor

        >>> # Download feature extractor from huggingface.co and cache.
        >>> feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")

        >>> # If feature extractor files are in a directory (e.g. feature extractor was saved using *save_pretrained('./test/saved_model/')*)
        >>> # feature_extractor = AutoFeatureExtractor.from_pretrained("./test/saved_model/")
        ```r    Nr¡   rœ   r¢   ÚconfigÚtrust_remote_codeTÚ
_from_autoÚfeature_extractor_typer¶   Úauto_mapÚcode_revisionz"Unrecognized feature extractor in z4. Should have a `feature_extractor_type` key in its z of z3, or one of the following `model_type` keys in its z: z, c              3   ó    K  — | ]  }|–— Œ y ­w)N© )Ú.0Úcs     r•   ú	<genexpr>z7AutoFeatureExtractor.from_pretrained.<locals>.<genexpr>‹  s   è ø€ Ò@sÀqÄÑ@sùs   ‚)r§   r¨   r©   rª   Úgetr«   r   Úget_feature_extractor_dictÚ
isinstancer   r   Úfrom_pretrainedrŠ   rŽ   rÁ   r–   ÚtyperŒ   r
   r	   ÚosÚpathÚisdirÚregister_for_auto_classÚ	from_dictr   r   Újoinr†   Úkeys)Úclsr—   r±   r    r½   r¾   Úconfig_dictr’   Úfeature_extractor_classÚfeature_extractor_auto_mapÚhas_remote_codeÚhas_local_codes               r•   rË   z$AutoFeatureExtractor.from_pretrained  s·  € ðR  Ÿ™Ð$4°dÓ;ˆØÐ%Ü�M‰Mð EÜôð �z‰z˜' 4Ó(Ð4Ü Ølóð ð -ˆF�7‰Oà—‘˜H dÓ+ˆØ"ŸJ™JÐ':¸DÓAÐØ#ˆˆ|Ñä/×JÑJÐKhÑsÐlrÑs‰ˆ�QØ"-§/¡/Ð2JÈDÓ"QÐØ%)Ð"Ø! [§_¡_°ZÀÓ%DÑDØ)4°ZÑ)@ÐAWÑ)XÐ&ð #Ð*Ð/IÐ/QÜ˜fÔ&6Ô7Ü#×3Ñ3Ø1ñØEVðØZ`ñ�ô '.¨fÐ6NÐPTÓ&UÐ#Ü�v˜zÔ*Ð/EÈÏÉÑ/XØ-3¯_©_Ð=SÑ-TÐ*à"Ð.Ü&GÐH_Ó&`Ð#à4¸DÐ@ˆØ0¸Ð<ÒiÄÀVÃÔPiÐ@iˆÜ5ØÐ<¸nÈoó
Ðñ Ñ0Ü&CØ*Ð,Iñ'ØMSñ'Ð#ð —
‘
˜?¨DÓ1ˆAÜ�w‰w�}‰}Ð:Ô;Ø'×?Ñ?ÔAØ4Ð*×4Ñ4°[ÑKÀFÑKÐKØ$Ð0Ø4Ð*×4Ñ4°[ÑKÀFÑKÐKä�&‹\Ô6Ñ6Ü&?ÄÀVÃÑ&MÐ#Ø4Ð*×4Ñ4°[ÑKÀFÑKÐKäØ0Ð1NÐ0Oð P3Ü3IÐ2JÈ$Ì{Èmð \(Ü(3 }°B°t·y±yÑ@sÔLk×LpÑLpÓLrÔ@sÓ7sÐ6tðvó
ð 	
r»   c                 ó4   — t         j                  | ||¬«       y)a0  
        Register a new feature extractor for this class.

        Args:
            config_class ([`PretrainedConfig`]):
                The configuration corresponding to the model to register.
            feature_extractor_class ([`FeatureExtractorMixin`]): The feature extractor to register.
        )Úexist_okN)rŒ   Úregister)Úconfig_classrÖ   rÛ   s      r•   rÜ   zAutoFeatureExtractor.registerŽ  s   € ô 	"×*Ñ*¨<Ð9PÐ[cÐ*Õdr»   N)F)r„   Ú
__module__Ú__qualname__Ú__doc__rº   Úclassmethodr   r†   rË   ÚstaticmethodrÜ   rÄ   r»   r•   r¶   r¶   ø   sH   „ ñò
ð Ù&Ð'FÓGñD
ó Hó ðD
ðL ò	eó ñ	er»   r¶   )NFNNNNF))rà   rˆ   r¯   rÍ   r¨   Úcollectionsr   Útypingr   r   r   Úconfiguration_utilsr   Údynamic_module_utilsr	   r
   Úfeature_extraction_utilsr   Úutilsr   r   r   r   Úauto_factoryr   Úconfiguration_autor   r   r   r   Ú
get_loggerr„   r¬   r†   rŒ   Ústrr–   ÚPathLikeÚboolr´   r¶   rÄ   r»   r•   ú<module>rï      sE  ðñ "ã Û Û 	Û Ý #ß (Ñ (õ 4ß \Ý >ß NÓ NÝ *÷ó ð 
ˆ×	Ñ	˜HÓ	%€á"-òJóL#Ð ñ\ -Ð-AÐCbÓcÐ ð°#ó ð4 48Ø Ø&*Ø(,Ø(,Ø"Ø"ñd!Ø#(¨¨b¯k©kÐ)9Ñ#:ðd!à˜˜c 2§;¡;Ð.Ñ/Ñ0ðd!ð ðd!ð ˜d‘^ð	d!ð
 �d˜3 ˜8‘nÑ%ðd!ð �E˜$ ˜)Ñ$Ñ%ðd!ð �s‰mðd!ð ód!÷N`eò `er»   