
    |-jZ                        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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j+        e,          Z-er e            Z.ee/e/dz  f         e0d<   n eg d          Z. eee.          Z1de/fdZ2 G d d          Z3ddgZ4dS )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)CONFIG_MAPPING_NAMES
AutoConfigmodel_type_to_module_name!replace_list_option_in_docstrings)AutoFeatureExtractor)AutoImageProcessor)AutoTokenizer)AutoVideoProcessorPROCESSOR_MAPPING_NAMES))aimv2CLIPProcessor)alignAlignProcessor)altclipAltCLIPProcessor)ariaAriaProcessor)audioflamingo3AudioFlamingo3Processor)
aya_visionAyaVisionProcessor)barkBarkProcessor)blipBlipProcessor)zblip-2Blip2Processor)bridgetowerBridgeTowerProcessor)	chameleonChameleonProcessor)chinese_clipChineseCLIPProcessor)clapClapProcessor)clipr   )clipsegCLIPSegProcessor)clvpClvpProcessor)cohere2_visionCohere2VisionProcessor)
cohere_asrCohereAsrProcessor)colmodernvbertColModernVBertProcessor)colpaliColPaliProcessor)colqwen2ColQwen2Processor)deepseek_vlDeepseekVLProcessor)deepseek_vl_hybridDeepseekVLHybridProcessor)diaDiaProcessor)edgetamSam2Processor)emu3Emu3Processor)ernie4_5_vl_moeErnie4_5_VLMoeProcessor)evollaEvollaProcessor)	exaone4_5Exaone4_5_Processor)flavaFlavaProcessor)	florence2Florence2Processor)fuyuFuyuProcessor)gemma3Gemma3Processor)gemma3nGemma3nProcessor)gemma4Gemma4Processor)gitGitProcessor)glm46vGlm46VProcessor)glm4vGlm4vProcessor)	glm4v_moerg   )	glm_imagerg   )glmasrGlmAsrProcessor)got_ocr2GotOcr2Processor)granite4_visionGranite4VisionProcessor)granite_speechGraniteSpeechProcessor)granite_speech_plusrq   )zgrounding-dinoGroundingDinoProcessor)groupvitr   )higgs_audio_v2HiggsAudioV2Processor)hubertWav2Vec2Processor)ideficsIdeficsProcessor)idefics2Idefics2Processor)idefics3Idefics3Processor)instructblipInstructBlipProcessor)instructblipvideoInstructBlipVideoProcessor)internvlInternVLProcessor)janusJanusProcessor)zkosmos-2Kosmos2Processor)z
kosmos-2.5Kosmos2_5Processor)kyutai_speech_to_textKyutaiSpeechToTextProcessor)lasr_ctcLasrProcessor)lasr_encoderr   )
layoutlmv2LayoutLMv2Processor)
layoutlmv3LayoutLMv3Processor)	layoutxlmLayoutXLMProcessor)lfm2_vlLfm2VlProcessor)lighton_ocrLightOnOcrProcessor)llama4Llama4Processor)llavaLlavaProcessor)
llava_nextLlavaNextProcessor)llava_next_videoLlavaNextVideoProcessor)llava_onevisionLlavaOnevisionProcessor)markuplmMarkupLMProcessor)
metaclip_2r   )zmgp-strMgpstrProcessor)minicpmv4_6MiniCPMV4_6Processor)mistral3PixtralProcessor)mllamaMllamaProcessor)zmm-grounding-dinors   )modernvbertr~   )	moonshinerx   )moonshine_streamingMoonshineStreamingProcessor)musicflamingoMusicFlamingoProcessor)zomdet-turboOmDetTurboProcessor)	oneformerOneFormerProcessor)ovis2Ovis2Processor)owlv2Owlv2Processor)owlvitOwlViTProcessor)paddleocr_vlPaddleOCRVLProcessor)	paligemmaPaliGemmaProcessor)parakeet_ctcParakeetProcessor)parakeet_tdtr   )perception_lmPerceptionLMProcessor)phi4_multimodalPhi4MultimodalProcessor)pi0PI0Processor)
pix2structPix2StructProcessor)pixtralr   )	pop2pianoPop2PianoProcessor)pp_chart2tablePPChart2TableProcessor)pp_formulanetPPFormulaNetProcessor)qianfan_ocrQianfanOCRProcessor)qwen2_5_omniQwen2_5OmniProcessor)
qwen2_5_vlQwen2_5_VLProcessor)qwen2_audioQwen2AudioProcessor)qwen2_vlQwen2VLProcessor)qwen3_5Qwen3VLProcessor)qwen3_5_moer   )qwen3_omni_moeQwen3OmniMoeProcessor)qwen3_vlr   )qwen3_vl_moer   )samSamProcessor)sam2rM   )sam3Sam3Processor)sam3_lite_textr   )sam_hqSamHQProcessor)seamless_m4tSeamlessM4TProcessor)sewrx   )zsew-drx   )shieldgemma2ShieldGemma2Processor)siglipSiglipProcessor)siglip2Siglip2Processor)smolvlmSmolVLMProcessor)speech_to_textSpeech2TextProcessor)speecht5SpeechT5Processor)t5gemma2r]   )t5gemma2_encoderr]   )trocrTrOCRProcessor)tvpTvpProcessor)udopUdopProcessor)	unispeechrx   )zunispeech-satrx   )vibevoice_asrVibeVoiceAsrProcessor)video_llavaVideoLlavaProcessor)viltViltProcessor)vipllavar   )zvision-text-dual-encoderVisionTextDualEncoderProcessor)voxtralVoxtralProcessor)voxtral_realtimeVoxtralRealtimeProcessor)wav2vec2rx   )zwav2vec2-bertrx   )zwav2vec2-conformerrx   )wavlmrx   )whisperWhisperProcessor)xclipXCLIPProcessor
class_namec                    t                                           D ]S\  }}| |v rJt          |          }t          j        d| d          }	 t          ||           c S # t          $ r Y Ow xY wTt          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PROCESSOR_MAPPING_extra_contentvalueshasattr)r  module_name
processorsmodule	processormain_modules         h/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/transformers/models/auto/processing_auto.pyprocessor_class_from_namer(     s   #:#@#@#B#B  Z##3K@@K,->->->@UVVFvz22222!    $ '5<<>>  	9j$//:== >
 ).99K{J'' 0{J///4s   A
A*)A*c                   h    e Zd ZdZd Ze ee          d                         Ze	dd            Z
dS )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__   s    _
 
 	
    c                 	                        dd          }                     dd          }dd<   d}d}d}fd|D             }|                    dddd	           t          |t          fi |}	|	Pt	          j        |fi \  }
}|
                    d
          }d|
                    di           v r|
d         d         }|8t          |t          fi |}|Qt          j	        |fi \  }
}|
                    d
d          }d|
                    di           v r|
d         d         }|ft          |t          fi |}|Qt          j        |fi \  }
}|
                    d
d          }d|
                    di           v r|
d         d         }|ht          |t          fi |}|S|Qt          j        |fi \  }
}|
                    d
d          }d|
                    di           v r|
d         d         }|t          |t          fi |}|yt!          |d          5 }t#          j        |          }
ddd           n# 1 swxY w Y   |
                    d
d          }d|
                    di           v r|
d         d         }|r	 t'          |t(                    st+          j        |fd|i}t/          |d
d          }t1          |d          rd|j        v r|j        d         }n# t4          $ r Y nw xY w|t7          |          }|du}|dupt9          |          t:          v }|o4|pt:          t9          |                   j                            d           }|r5d|v r|                     d          d         }nd}tC          |||||          }|rL|rJ|sHtE          ||fi }                     dd          }|#                                  |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 # tP          $ r Y !w xY wt5          d| d          )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_agentc                 *    i | ]}|v ||         S  r>  ).0keykwargss     r'  
<dictcomp>z1AutoProcessor.from_pretrained.<locals>.<dictcomp>D  s%    ]]]3sV\}}c6#;}}}r/  F) _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_pretrainedr  r!  rG  
ValueErrorr(  typer  
__module__
startswithsplitr   r   register_for_auto_classr   r   r   r   	Exception)clspretrained_model_name_or_pathrA  r1  r2  rF  processor_auto_map_hub_valid_kwargs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'  rU  zAutoProcessor.from_pretrained   s   D Hd++"JJ':DAA#|!

 ^]]]:K]]]!!499>;@ 	
 	
 	
 !,,I> p p]o p p ,+>?\gg`fggNK)oo.?@@O+//*b"A"AAA%0%<_%M""'2-/E( (I[( ($ (3!5!NOl!w!wpv!w!wQ"-//2CT"J"J"kooj"&E&EEE)4Z)@)Q& (/+613G, ,K], ,( ,7%7%P5& &9?& &NK '2oo6G&N&NO&+//*b*I*III-8-D_-U*'/+613I, ,M_, ,( ,7O<S%;%V5& &9?& &NK '2oo6G&N&NO&+//*b*I*III-8-D_-U*"$/-/D% %HZ% %! %0/'BBB 4f"&)F"3"3K4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 #.//2CT"J"J"kooj"&E&EEE)4Z)@)Q&"!&*:;; '75 IZ^d F #*&2CT"J"J6:.. J?fo3U3U)/)I&    
 &7HHO,D8(4YVHY8Y, 1>0f>
ZZ0021  	))) 2 8 8 > >q A $ 9!#@.Racp! !  	l0 	l9L 	l;"$A EK O 

?D11A335552?2- ARV\   (2?2- ARV\   &\\...$T&\\2BC`kkdjkkk $%79KMab 	 	E,u,1 EVZ`         g0M g g g
 
 	
s7   (I		IIA K4 4
L LQ++
Q87Q8Fc                 @    t                               | ||           dS )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)r  register)config_classrF  rn  s      r'  ro  zAutoProcessor.register  s%     	""<8"TTTTTr/  N)F)r  rX  __qualname____doc__r.  classmethodr   r   rU  staticmethodro  r>  r/  r'  r*  r*     s         
 
 
 &&'>??[
 [
 @? [[
z 	U 	U 	U \	U 	U 	Ur/  r*  r  )5rr  r  rR  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   configuration_autor   r   r   r   feature_extraction_autor   image_processing_autor   tokenization_autor   video_processing_autor   
get_loggerr  loggerr   str__annotations__r  r(  r*  __all__r>  r/  r'  <module>r     sz           # # # # # #             4 3 3 3 3 3 \ \ \ \ \ \ \ \ > > > > > > : : : : : : . . . . . . 8 8 8 8 8 8 g g g g g g g g g g g g g g 8 8 8 8 8 8 * * * * * *            : 9 9 9 9 9 5 5 5 5 5 5 , , , , , , 5 5 5 5 5 5 
	H	%	% W =HKMM[cDj9IIII)kP	
 P	
 P	
R Rh %$%9;RSS #    0wU wU wU wU wU wU wU wUt 
0r/  