§
    \�’jŒQ  ã                   ó¤  — U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZ ddlmZmZmZmZmZmZmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZm Z m!Z!  ej"        e#¦  «        Z$er& e¦   «         Zee%e&e%dz  e%dz  f         f         e'd<   n eg d¢¦  «        Z( ej)        e(¦  «          ej*        ¦   «         D ]\  Z+Z,e,Z- e¦   «         sdZ-e-ee+<   Œ eee¦  «        Z.de%fd„Z/	 	 	 	 	 	 d!de%ej0        z  de%ej0        z  dz  de1de2e%e%f         dz  de1e%z  dz  de%dz  de1fd„Z3 ed¬¦  «         G d„ d¦  «        ¦   «         Z4d dgZ5dS )"zAutoVideoProcessor class.é    N)ÚOrderedDict)ÚTYPE_CHECKINGé   )ÚPreTrainedConfig)Úget_class_from_dynamic_moduleÚresolve_trust_remote_code)ÚCONFIG_NAMEÚIMAGE_PROCESSOR_NAMEÚPROCESSOR_NAMEÚVIDEO_PROCESSOR_NAMEÚcached_fileÚis_torchvision_availableÚloggingÚsafe_load_json_file)Úrequires)ÚBaseVideoProcessoré   )Ú_LazyAutoMapping)ÚVIDEO_PROCESSOR_MAPPING_NAMES)ÚCONFIG_MAPPING_NAMESÚ
AutoConfigÚmodel_type_to_module_nameÚ!replace_list_option_in_docstringsr   ))Úcosmos3_omniÚQwen3VLVideoProcessor)Ú	exaone4_5ÚQwen2VLVideoProcessor)ÚinstructblipÚInstructBlipVideoVideoProcessor)Úpe_audio_videoÚPeVideoVideoProcessor)Úqwen2_5_omnir   )Ú
qwen2_5_vlr   )Úqwen3_5r   )Úqwen3_5_moer   )Úqwen3_omni_moer   )Úqwen3_vl_moer   )Ú
videoprismÚLlavaOnevisionVideoProcessorÚ
class_namec                 ó´  — t          j        ¦   «         D ]U\  }}| |k    rJt          |¦  «        }t          j        d|› �d¦  «        }	 t          || ¦  «        c S # t          $ r Y ŒQw xY wŒVt          j         	                    ¦   «         D ]}t          |dd ¦  «        | k    r|c S Œt          j        d¦  «        }t          || ¦  «        rt          || ¦  «        S d S )Nú.ztransformers.modelsÚ__name__Útransformers)r   Úitemsr   Ú	importlibÚimport_moduleÚgetattrÚAttributeErrorÚVIDEO_PROCESSOR_MAPPINGÚ_extra_contentÚvaluesÚhasattr)r*   Úmodule_nameÚ	extractorÚmoduleÚmain_modules        ú\C:\Projects\DSCons\.venv\Lib\site-packages\transformers\models\auto\video_processing_auto.pyÚvideo_processor_class_from_namer=   T   s  € Ý"?Ô"EÑ"GÔ"Gð ð Ñˆ�YØ˜Ò"Ð"Ý3°KÑ@Ô@ˆKåÔ,Ð->°Ð->Ð->Ð@UÑVÔVˆFðÝ˜v zÑ2Ô2Ð2Ð2Ð2øÝ!ð ð ð Ø�ðøøøð #õ -Ô;×BÒBÑDÔDð ð ˆ	Ý�9˜j¨$Ñ/Ô/°:Ò=Ð=ØÐÐÐð >õ
 Ô)¨.Ñ9Ô9€KÝˆ{˜JÑ'Ô'ð 0Ý�{ JÑ/Ô/Ð/àˆ4s   ÁAÁ
A&Á%A&FÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚproxiesÚtokenÚrevisionÚlocal_files_onlyc                 óT  ‡ ‡‡‡‡‡‡‡— t          ‰ t          ‰‰‰‰‰‰dd¬¦
  «
        }ˆˆˆˆ ˆˆˆˆfd„t          t          fD ¦   «         }	|	r|	d         nd}
|
s|st                               d¦  «         i S d}|�t          |¦  «        }d|v r|d         }|
�|€t          |
¦  «        }|pi S )aþ
  
    Loads the video processor configuration from a pretrained model video processor 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
              [`~BaseVideoProcessor.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.
        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 `hf auth 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 video processor 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 video processor.

    Examples:

    ```python
    # Download configuration from huggingface.co and cache.
    video_processor_config = get_video_processor_config("llava-hf/llava-onevision-qwen2-0.5b-ov-hf")
    # This model does not have a video processor config so the result will be an empty dict.
    video_processor_config = get_video_processor_config("FacebookAI/xlm-roberta-base")

    # Save a pretrained video processor locally and you can reload its config
    from transformers import AutoVideoProcessor

    video_processor = AutoVideoProcessor.from_pretrained("llava-hf/llava-onevision-qwen2-0.5b-ov-hf")
    video_processor.save_pretrained("video-processor-test")
    video_processor = get_video_processor_config("video-processor-test")
    ```F)	Úfilenamer?   r@   rA   rB   rC   rD   Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesc                 óN   •— g | ]!}t          ‰|‰‰‰‰	‰‰d d d ¬¦  «        xŠ	 ®‰‘Œ"S )F)
rF   r?   r@   rA   rB   rC   rD   rG   rH   Ú'_raise_exceptions_for_connection_errors)r   )
Ú.0rF   r?   r@   rD   r>   rA   Úresolved_filerC   rB   s
     €€€€€€€€r<   ú
<listcomp>z.get_video_processor_config.<locals>.<listcomp>º   sm   ø€ ð &ð &ð &àå(Ø-Ø!Ø#Ø-ØØØ!Ø!1Ø16Ø6;Ø8=ðñ ô ð ˆMð ðð 	ðð ð ó    r   Nz8Could not locate the video processor configuration file.Úvideo_processor)r   r   r   r
   ÚloggerÚinfor   )r>   r?   r@   rA   rB   rC   rD   ÚkwargsÚresolved_processor_fileÚresolved_video_processor_filesÚresolved_video_processor_fileÚvideo_processor_dictÚprocessor_dictrL   s   ```````      @r<   Úget_video_processor_configrX   l   s0  øøøøøøøø€ õD *Ø%ÝØØ%ØØØØ)Ø).Ø.3ðñ ô Ðð&ð &ð &ð &ð &ð &ð &ð &ð &ð &ð &å-Õ/CÐDð&ñ &ô &Ð"ð( JhÐ$qÐ$BÀ1Ô$EÐ$EÐmqÐ!ð )ð Ð1Hð Ý�ŠÐNÑOÔOÐOØˆ	ð
  ÐØÐ*Ý,Ð-DÑEÔEˆØ Ð.Ð.Ø#1Ð2CÔ#DÐ à$Ð0Ð5IÐ5QÝ2Ð3PÑQÔQÐàÐ% 2Ð%rN   )ÚvisionÚtorchvision)Úbackendsc                   ój   — e Zd ZdZd„ Ze ee¦  «        d„ ¦   «         ¦   «         Ze		 dd„¦   «         Z
dS )ÚAutoVideoProcessora%  
    This is a generic video processor class that will be instantiated as one of the video processor classes of the
    library when created with the [`AutoVideoProcessor.from_pretrained`] class method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
    c                 ó    — t          d¦  «        ‚)Nz‡AutoVideoProcessor is designed to be instantiated using the `AutoVideoProcessor.from_pretrained(pretrained_model_name_or_path)` method.)ÚOSError)Úselfs    r<   Ú__init__zAutoVideoProcessor.__init__í   s   € Ýðdñ
ô 
ð 	
rN   c                 óV  — |                      dd¦  «        }|                      dd¦  «        }d|d<   t          j        |fi |¤Ž\  }}|                     dd¦  «        }d}	d|                     di ¦  «        v r|d         d         }	|€}|	€{|                      d	d¦  «        }
|
�'|
                     d
d¦  «        }t          |¦  «        �|}d|                     di ¦  «        v r$|d         d         }|                     d
d¦  «        }	|€r	 t          |t          ¦  «        st          j	        |fd|i|¤Ž}t          |dd¦  «        }t          |d¦  «        rd|j        v r|j        d         }	n# t          $ r Y nw xY w|�t          |¦  «        }|	du}|dupt          |¦  «        t          v }|o4|pt          t          |¦  «                 j                             d¦  «         }|r5d|	v r|	                     d¦  «        d         }nd}t'          |||||¦  «        }|rO|rM|sK|	}t)          ||fi |¤Ž}|                      dd¦  «        }|                     ¦   «           |j	        |g|¢R i |¤ŽS |� |j	        |g|¢R i |¤ŽS t          |¦  «        t          v r-t          t          |¦  «                 }|� |j	        |g|¢R i |¤ŽS t-          ¦   «         st          |› d�¦  «        ‚t          d|› dt.          › dt0          › dt0          › dd                     d„ t4          D ¦   «         ¦  «        › �
¦  «        ‚)a   
        Instantiate one of the video processor classes of the library from a pretrained model vocabulary.

        The video processor 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 video_processor hosted inside a model repo on
                  huggingface.co.
                - a path to a *directory* containing a video processor file saved using the
                  [`~video_processing_utils.BaseVideoProcessor.save_pretrained`] method, e.g.,
                  `./my_model_directory/`.
                - a path to a saved video processor 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 video processor 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 video processor files and override the cached versions if
                they exist.
            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 `hf auth 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 video processor object. If `True`, then this
                functions returns a `Tuple(video_processor, unused_kwargs)` where *unused_kwargs* is a dictionary
                consisting of the key/value pairs whose keys are not video processor attributes: i.e., the part of
                `kwargs` which has not been used to update `video_processor` 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 video processor attributes will be used to override the
                loaded values. Behavior concerning key/value pairs whose keys are *not* video processor 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 AutoVideoProcessor

        >>> # Download video processor from huggingface.co and cache.
        >>> video_processor = AutoVideoProcessor.from_pretrained("llava-hf/llava-onevision-qwen2-0.5b-ov-hf")

        >>> # If video processor files are in a directory (e.g. video processor was saved using *save_pretrained('./test/saved_model/')*)
        >>> # video_processor = AutoVideoProcessor.from_pretrained("./test/saved_model/")
        ```ÚconfigNÚtrust_remote_codeTÚ
_from_autoÚvideo_processor_typer]   Úauto_mapÚimage_processor_typeÚImageProcessorÚVideoProcessorÚAutoImageProcessorztransformers.z--r   Úcode_revisionzT requires `torchvision` to be installed. Please install `torchvision` and try again.z Unrecognized video processor in z2. Should have a `video_processor_type` key in its z of z3, or one of the following `model_type` keys in its z: z, c              3   ó   K  — | ]}|V — Œd S )N© )rK   Úcs     r<   ú	<genexpr>z5AutoVideoProcessor.from_pretrained.<locals>.<genexpr>‹  s"   è è € Ð@jÐ@jÀqÀÐ@jÐ@jÐ@jÐ@jÐ@jÐ@jrN   )Úpopr   Úget_video_processor_dictÚgetÚreplacer=   Ú
isinstancer   r   Úfrom_pretrainedr2   r7   rg   Ú
ValueErrorÚtyper4   Ú
__module__Ú
startswithÚsplitr   r   Úregister_for_auto_classr   r   r	   Újoinr   )Úclsr>   ÚinputsrR   rc   rd   Úconfig_dictÚ_Úvideo_processor_classÚvideo_processor_auto_mapÚimage_processor_classÚvideo_processor_class_inferredÚimage_processor_auto_mapÚhas_remote_codeÚhas_local_codeÚexplicit_local_codeÚupstream_repoÚ	class_refs                     r<   rv   z"AutoVideoProcessor.from_pretrainedó   sd  € ðL —’˜H dÑ+Ô+ˆØ"ŸJšJÐ':¸DÑAÔAÐØ#ˆˆ|Ñå+ÔDÐEbÐmÐmÐflÐmÐm‰ˆ�QØ +§¢Ð0FÈÑ MÔ MÐØ#'Ð Ø ;§?¢?°:¸rÑ#BÔ#BÐBÐBØ'2°:Ô'>Ð?SÔ'TÐ$ð !Ð(Ð-EÐ-MØ$/§O¢OÐ4JÈDÑ$QÔ$QÐ!Ø$Ð0Ø1F×1NÒ1NÐO_ÐaqÑ1rÔ1rÐ.õ 3Ð3QÑRÔRÐ^Ø,JÐ)Ø# {§¢°zÀ2Ñ'FÔ'FÐFÐFØ+6°zÔ+BÐCWÔ+XÐ(Ø+C×+KÒ+KÐL\Ð^nÑ+oÔ+oÐ(ð !Ð(ðÝ! &Õ*:Ñ;Ô;ð Ý'Ô7Ø5ðð ØIZðØ^dðð �Fõ
 )0°Ð8NÐPTÑ(UÔ(UÐ%Ý˜6 :Ñ.Ô.ð UÐ3GÈ6Ì?Ð3ZÐ3ZØ/5¬Ð?SÔ/TÐ,øøÝð ð ð ð �ðøøøð
 !Ð,Ý$CÐDYÑ$ZÔ$ZÐ!à2¸$Ð>ˆØ.°dÐ:Ðe½dÀ6¹l¼lÕNeÐ>eˆØ,ð 1Ø!ÐJÕ%<½TÀ&¹\¼\Ô%JÜ
—Z’Z Ñ0Ô0ð21Ðð ð 	ØÐ/Ð/Ð/Ø 8× >Ò >¸tÑ DÔ DÀQÔ G��à $�Ý 9Ø!Ð#@À.ÐRaÐcpñ!ô !Ðð ð 	oÐ0ð 	oÐ9Lð 	oØ0ˆIÝ$AÀ)ÐMjÐ$uÐ$uÐntÐ$uÐ$uÐ!Ø—
’
˜?¨DÑ1Ô1ˆAØ!×9Ò9Ñ;Ô;Ð;Ø8Ð(Ô8Ð9VÐjÐY_ÐjÐjÐjÐciÐjÐjÐjØ"Ð.Ø8Ð(Ô8Ð9VÐjÐY_ÐjÐjÐjÐciÐjÐjÐjå�&‰\Œ\Õ4Ð4Ð4Ý$;½DÀ¹L¼LÔ$IÐ!Ø$Ð0Ø<Ð,Ô<Ð=ZÐnÐ]cÐnÐnÐnÐgmÐnÐnÐnõ (Ñ)Ô)ð 	ÝØ0ð  Gð  Gð  Gñô ð õ ðmÐ/Lð mð mÝ1Eðmð mÝKVðmð må(3ðmð mà7;·y²yÐ@jÐ@jÕLiÐ@jÑ@jÔ@jÑ7jÔ7jðmð mñ
ô 
ð 	
s   ÄA E( Å(
E5Å4E5Fc                 ó@   — t                                | ||¬¦  «         dS )a7  
        Register a new video processor for this class.

        Args:
            config_class ([`PreTrainedConfig`]):
                The configuration corresponding to the model to register.
            video_processor_class ([`BaseVideoProcessor`]):
                The video processor to register.
        )Úexist_okN)r4   Úregister)Úconfig_classr‚   r�   s      r<   rŽ   zAutoVideoProcessor.registerŽ  s'   € õ 	 ×(Ò(¨Ð7LÐW_Ð(Ñ`Ô`Ð`Ð`Ð`rN   N)F)r-   ry   Ú__qualname__Ú__doc__ra   Úclassmethodr   r   rv   ÚstaticmethodrŽ   rn   rN   r<   r]   r]   ä   s�   € € € € € ðð ð
ð 
ð 
ð Ø&Ð&Ð'DÑEÔEðW
ð W
ñ FÔEñ „[ðW
ðr ð ðað að añ „\ðað að arN   r]   r4   )NFNNNF)6r‘   r0   ÚosÚcollectionsr   Útypingr   Úconfiguration_utilsr   Údynamic_module_utilsr   r   Úutilsr	   r
   r   r   r   r   r   r   Úutils.import_utilsr   Úvideo_processing_utilsr   Úauto_factoryr   Úauto_mappingsr   Úconfiguration_autor   r   r   r   Ú
get_loggerr-   rP   ÚstrÚtupleÚ__annotations__Ú%MISSING_VIDEO_PROCESSOR_MAPPING_NAMESÚupdater/   Ú
model_typeÚvideo_processorsÚfast_video_processor_classr4   r=   ÚPathLikeÚboolÚdictrX   r]   Ú__all__rn   rN   r<   ú<module>r¬      sƒ  ðð  Ð Ð à Ð Ð Ð Ø 	€	€	€	Ø #Ð #Ð #Ð #Ð #Ð #Ø  Ð  Ð  Ð  Ð  Ð  ð 4Ð 3Ð 3Ð 3Ð 3Ð 3Ø \Ð \Ð \Ð \Ð \Ð \Ð \Ð \ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð +Ð *Ð *Ð *Ð *Ð *Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø *Ð *Ð *Ð *Ð *Ð *Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð ð ð ð ð ð ð 
ˆÔ	˜HÑ	%Ô	%€ð ð Pð VaÐU`ÑUbÔUbÐ! ;¨s°E¸#À¹*ÀcÈDÁjÐ:PÔ4QÐ/QÔ#RÐbÐbÑbÐbð -8¨Kð	
ð 	
ð 	
ñ-ô -Ð)ð )Ð!Ô(Ð)NÑOÔOÐOà$GÐ$AÔ$GÑ$IÔ$Ið Kð KÑ €JÐ Ø!1Ðð $Ð#Ñ%Ô%ð *Ø%)Ð"à0JÐ! *Ñ-Ð-à*Ð*Ð+?ÐA^Ñ_Ô_Ð ð°ð ð ð ð ð4 +/Ø Ø%)Ø#ØØ"ðu&ð u&Ø#&¨¬Ñ#4ðu&à�R”[Ñ  4Ñ'ðu&ð ðu&ð �#�s�(Œ^˜dÑ"ð	u&ð
 �#‰:˜Ñðu&ð �D‰jðu&ð ðu&ð u&ð u&ð u&ðp 
€Ð,Ð-Ñ-Ô-ðxað xað xað xað xañ xaô xañ .Ô-ðxaðv %Ð&:Ð
;€€€rN   