
    ^j^F                        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 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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$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z,  ejZ                  e.      Z/er e       Zee0e0dz  f   e1d<   n eg d      Z2 ejf                  e2        ee!e      Z4de0fdZ5 G d d      Z6ddgZ7y)zAutoProcessor class.    N)OrderedDict)TYPE_CHECKING   )PreTrainedConfig)get_class_from_dynamic_moduleresolve_trust_remote_code)FeatureExtractionMixin)ImageProcessingMixin)ProcessorMixin)TOKENIZER_CONFIG_FILE)FEATURE_EXTRACTOR_NAMEPROCESSOR_NAMEVIDEO_PROCESSOR_NAMEcached_filelogging)BaseVideoProcessor   )_LazyAutoMapping)PROCESSOR_MAPPING_NAMES)CONFIG_MAPPING_NAMES
AutoConfigmodel_type_to_module_name!replace_list_option_in_docstrings)AutoFeatureExtractor)AutoImageProcessor)AutoTokenizer)AutoVideoProcessorr   ))aimv2CLIPProcessor)diffusion_gemmaGemma4Processor)edgetamSam2Processor)	glm4v_moeGlm4vProcessor)granite_speech_plusGraniteSpeechProcessor)groupvitr   )hubertWav2Vec2Processor)inkling_mm_modelInklingProcessor)lasr_ctcLasrProcessor)lasr_encoderr.   )
metaclip_2r   )mistral3PixtralProcessor)zmm-grounding-dinoGroundingDinoProcessor)modernvbertIdefics3Processor)	moonshiner*   )parakeet_ctcParakeetProcessor)parakeet_rnntr8   )parakeet_tdtr8   )qwen3_5Qwen3VLProcessor)qwen3_5_moer<   )qwen3_vl_moer<   )sam3_lite_textSam3Processor)sewr*   )zsew-dr*   )t5gemma2Gemma3Processor)t5gemma2_encoderrC   )	unispeechr*   )zunispeech-satr*   )vipllavaLlavaProcessor)zwav2vec2-conformerr*   )wavlmr*   
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)r   itemsr   	importlibimport_modulegetattrAttributeErrorPROCESSOR_MAPPING_extra_contentvalueshasattr)rI   module_name
processorsmodule	processormain_modules         s/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/auto/processing_auto.pyprocessor_class_from_namer]   Z   s    #:#@#@#B Z#3K@K,,q->@UVFvz22 '55<<> 	9j$/:= )).9K{J'{J// " s   B99	CCc                   N    e Zd ZdZd Ze ee      d               Ze	dd       Z
y)AutoProcessora  
    This is a generic processor class that will be instantiated as one of the processor classes of the library when
    created with the [`AutoProcessor.from_pretrained`] class method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
    c                     t        d      )Nz}AutoProcessor is designed to be instantiated using the `AutoProcessor.from_pretrained(pretrained_model_name_or_path)` method.)OSError)selfs    r\   __init__zAutoProcessor.__init__z   s    _
 	
    c                 X   |j                  dd      }|j                  dd      }d|d<   d}d}d}|D ci c]  }||v s|||    }	}|	j                  dddd       t        |t        fi |	}
|
Ft	        j
                  |fi |\  }}|j                  d	      }d
|j                  di       v r|d   d
   }|t        |t        fi |	}|Gt        j                  |fi |\  }}|j                  d	d      }d
|j                  di       v r|d   d
   }|Zt        |t        fi |	}|Gt        j                  |fi |\  }}|j                  d	d      }d
|j                  di       v r|d   d
   }|\t        |t        fi |	}|I|Gt        j                  |fi |\  }}|j                  d	d      }d
|j                  di       v r|d   d
   }|lt        |t        fi |	}|Yt!        |d      5 }t#        j$                  |      }ddd       j                  d	d      }d
|j                  di       v r|d   d
   }|_	 t'        |t(              st+        j,                  |fd|i|}t/        |d	d      }t1        |d      rd
|j2                  v r|j2                  d
   }|t7        |      }|du}|duxs t9        |      t:        v }|xr0 |xs t:        t9        |         j<                  j?                  d       }|s,|r*d|v r|jA                  d      d   }nd}tC        |||||      }|rH|rF|sDtE        ||fi |}|j                  dd      }|jG                           |j,                  |fd|i|S | |j,                  |fd|i|S t9        |      t:        v r"t;        t9        |         j,                  |fi |S tH        tJ        tL        tN        fD ]  }	  |j,                  |fd|i|c S  t5        d| d      c c}w # 1 sw Y   xY w# t4        $ r Y }w xY w# tP        $ r Y Xw xY w)a3  
        Instantiate one of the processor classes of the library from a pretrained model vocabulary.

        The 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):

        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 processor files saved using the `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 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.
            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 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 AutoProcessor

        >>> # Download processor from huggingface.co and cache.
        >>> processor = AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h")

        >>> # If processor files are in a directory (e.g. processor was saved using *save_pretrained('./test/saved_model/')*)
        >>> # processor = AutoProcessor.from_pretrained("./test/saved_model/")
        ```configNtrust_remote_codeT
_from_auto)		cache_dirforce_downloadproxiestokenrevisionlocal_files_only	subfolder	repo_type
user_agentF) _raise_exceptions_for_gated_repo%_raise_exceptions_for_missing_entries'_raise_exceptions_for_connection_errorsprocessor_classr_   auto_mapzutf-8)encodingztransformers.z--r   code_revisionz!Unrecognized processing class in z. Can't instantiate a processor, a tokenizer, an image processor, a video processor or a feature extractor for this model. Make sure the repository contains the files of at least one of those processing classes.))popupdater   r   r   get_processor_dictgetr   r
   get_image_processor_dictr   r   get_video_processor_dictr	   get_feature_extractor_dictr   openjsonload
isinstancer   r   from_pretrainedrQ   rV   rv   
ValueErrorr]   typerS   
__module__
startswithsplitr   r   register_for_auto_classr   r   r   r   	Exception)clspretrained_model_name_or_pathkwargsrf   rg   ru   processor_auto_map_hub_valid_kwargskeycached_file_kwargsprocessor_config_fileconfig_dict_preprocessor_config_filetokenizer_config_filereaderhas_remote_codehas_local_codeexplicit_local_codeupstream_repoklasss                        r\   r   zAutoProcessor.from_pretrained   sq   D Hd+"JJ':DA#|!

 ;L]3sV\}c6#;.]]!!499>;@	
 !,,I> p]o p ,+>>?\g`fgNK)oo.?@O+//*b"AA%0%<_%M""'2-/E(I[($ (3!5!N!NOl!wpv!wQ"-//2CT"J"kooj"&EE)4Z)@)Q& (/+613G,K],( ,7%7%P%P5&9?&NK '2oo6G&NO&+//*b*II-8-D_-U*'/+613I,M_,( ,7O<S%;%V%V5&9?&NK '2oo6G&NO&+//*b*II-8-D_-U*"$/-/D%HZ%! %0/'B 4f"&))F"3K4 #.//2CT"J"kooj"&EE)4Z)@)Q&"!&*:;'775IZ^dF #*&2CT"J6:.?foo3U)/)I& &7HO,D8(4YVHY8Y, 1>0f>
*ZZ021 /)) 2 8 8 >q A $ 9!#@.Racp! 09L;"$AEKO 

?D1A3352?22-ARV\  (2?22-ARV\  &\..$T&\2BBC`kdjkk $%79KMab 	E,u,,1EVZ` 	 /0M/N Og g
 	
G ^x4 4,   \  s;   	O;O;/P >AP P P
	PP	P)(P)c                 4    t         j                  | ||       y)a  
        Register a new processor for this class.

        Args:
            config_class ([`PreTrainedConfig`]):
                The configuration corresponding to the model to register.
            processor_class ([`ProcessorMixin`]): The processor to register.
        )exist_okN)rS   register)config_classru   r   s      r\   r   zAutoProcessor.register_  s     	""<8"Trd   N)F)rL   r   __qualname____doc__rc   classmethodr   r   r   staticmethodr    rd   r\   r_   r_   r   sH    
 &'>?[
 @ [
z 	U 	Urd   r_   rS   )8r   rO   r   collectionsr   typingr   configuration_utilsr   dynamic_module_utilsr   r   feature_extraction_utilsr	   image_processing_utilsr
   processing_utilsr   tokenization_pythonr   utilsr   r   r   r   r   video_processing_utilsr   auto_factoryr   auto_mappingsr   configuration_autor   r   r   r   feature_extraction_autor   image_processing_autor   tokenization_autor   video_processing_autor   
get_loggerrL   loggerstr__annotations__MISSING_PROCESSOR_MAPPING_NAMESrz   rS   r]   r_   __all__r   rd   r\   <module>r      s       #   4 \ > : . 8 g g 8 * 2  : 5 , 5 
		H	% =HM[cDj9I&1 	
"'#F #""#BC$%9;RS # 0wU wUt 
0rd   