+
    œ°³j”  ã                   óÜ   € R t ^RIHt ^RIHt ^RIHtHtHtH	t	 ^RI
HtHt ^RIHtHt ]P                   ! ]4      tRt ! R R]R	R
7      t ! R R]R	R
7      t] ! R R]4      4       tR.tR# )z
Processor class for Janus.
)ÚBatchFeature©Ú
ImageInput)ÚProcessingKwargsÚProcessorMixinÚ
TextKwargsÚUnpack)ÚPreTokenizedInputÚ	TextInput)Úauto_docstringÚloggingz¼You are a helpful language and vision assistant. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language.

c                   ó0   a € ] tR t^"t o RtV 3R ltRtV tR# )ÚJanusTextKwargsa_  
generation_mode (`str`, *optional*, defaults to `"text"`):
    The generation mode indicating which modality to generate. Can be one of `"text"` or `"image"`. When set
    to `"text"`, the processor prepares inputs for text generation. When set to `"image"`, it prepares inputs
    for image generation by appending image start tokens to the prompt.
c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )é   Úgeneration_mode)Ústr)ÚformatÚ__classdict__s   "€Úk/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/janus/processing_janus.pyÚ__annotate__ÚJanusTextKwargs.__annotate__"   s   ø‡ ‚ ñ Ñò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r   "   s   ø‡ € ñ÷ ƒ r   r   F)Útotalc                   óH   a € ] tR t^-t o RRRRRRR/RR	R
//tV 3R ltRtV tR# )ÚJanusProcessorKwargsÚtext_kwargsÚpaddingFÚpadding_sideÚleftr   ÚtextÚcommon_kwargsÚreturn_tensorsÚptc                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r   r&   )r   )r   r   s   "€r   r   Ú!JanusProcessorKwargs.__annotate__-   s   ø‡ ‚ Ù Ñ ò r   r   N)r   r   r   r   Ú	_defaultsr   r    r!   r"   s   @r   r%   r%   -   s4   ø‡ € ð 	˜	 5¨.¸&ÐBSÐU[Ð\ØÐ*¨DÐ1ð€I÷ ƒ r   r%   c                   óš   a a€ ] tR t^5t o]tRV3R lV 3R lllt]RV3R lV 3R lll4       tV3R lR lt	V3R lR lt
RR	 ltR
tVtV ;t# )ÚJanusProcessorc                ó:   <€ V ^8„  d   QhRS[ R,          RS[RS[/# )r   Úchat_templateNÚuse_default_system_promptÚnum_image_tokens)r   ÚboolÚint)r   r   s   "€r   r   ÚJanusProcessor.__annotate__9   s4   ø€ ÷ Rñ Rñ ˜T•zð	Rñ
 $(ðRñ ñRr   c                ó¨   <€ WPn         VP                  V n        VP                  V n        VP                  V n        W@n        \        SV `!  WVR7       R# )zó
use_default_system_prompt (`bool`, *optional*, defaults to `False`):
    Use default system prompt for Text Generation.
num_image_tokens (`int`, *optional*, defaults to `576`):
    The number of placeholder image tokens needed per one image.
)r4   N)	r6   Úimage_tokenÚ	boi_tokenÚimage_start_tokenÚ	eoi_tokenÚimage_end_tokenr5   ÚsuperÚ__init__)ÚselfÚimage_processorÚ	tokenizerr4   r5   r6   ÚkwargsÚ	__class__s   &&&&&&,€r   rA   ÚJanusProcessor.__init__9   sM   ø€ ð !1ÔØ$×0Ñ0ˆÔØ!*×!4Ñ!4ˆÔØ(×2Ñ2ˆÔØ)BÔ&ä‰Ñ˜À=ÐÖQr   c                ó    <€ V ^8„  d   QhRS[ S[,          S[S[ ,          ,          S[S[,          ,          RS[R,          RS[S[,          RS[/# )r   r*   ÚimagesNrE   Úreturn)r
   r	   Úlistr   r   r%   r   )r   r   s   "€r   r   r9   Q   sX   ø€ ÷ ñ áÑ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWðñ ˜TÕ!ðñ Ñ-Õ.ð	ñ
 
ñr   c                ó~  <€ V P                   ! \        3RV P                  P                  /VB pVR,          P	                  R4      pV P
                  '       d"   VR8X  d   V Uu. uF  p\         V 2NK  	  ppM%VR8X  d   V Uu. uF  qf V P                   2NK  	  pp\        SV `$  ! RRVRV/VB pV# u upi u upi )a  
Returns:
    [`BatchFeature`]: A [`BatchFeature`] with the following fields:

    - **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
    - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
      `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
      `None`).
    - **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
Útokenizer_init_kwargsr&   r   r*   ÚimagerI   r   )
Ú_merge_kwargsr%   rD   Úinit_kwargsÚpopr5   ÚDEFAULT_SYSTEM_PROMPTr=   r@   Ú__call__)	rB   r*   rI   rE   Úoutput_kwargsr   ÚsampleÚmodel_inputsrF   s	   &&&,    €r   rS   ÚJanusProcessor.__call__P   sÓ   ø€ ð$ ×*Ò*Ü ñ
Ø8<¿¹×8RÑ8Rð
ØV\ñ
ˆð (¨Õ6×:Ñ:Ð;LÓMˆØ×)×)Ð)¨oÀÔ.GÙEIÓJÁT¸6Ô,Ð-¨f¨XÓ6ÁTˆDÐJˆDØ Ô'ÙFJÓKÁd¸F�h˜t×5Ñ5Ð6Ó7ÁdˆDÐKä‘wÒ'ÑR¨vÐR¸DÐRÀMÑRˆØÐùò KùâKs   Á$B5ÂB:c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r   Úimage_inputsÚ	image_idxrJ   )Údictr8   r   )r   r   s   "€r   r   r9   o   s#   ø€ ÷ ñ ±ð Áð ÑSVñ r   c                ó„   € V P                   V P                  V P                  ,          ,           V P                  ,           pV# )N)r=   r;   r6   r?   )rB   rY   rZ   rE   Úone_img_tokenss   &&&, r   Úreplace_image_tokenÚ"JanusProcessor.replace_image_tokeno   s5   € Ø×/Ñ/°4×3CÑ3CÀd×F[ÑF[Õ3[Õ\Ð_c×_sÑ_sÕsˆØÐr   c                ó    <€ V ^8„  d   QhRS[ /# )r   rI   r   )r   r   s   "€r   r   r9   s   s   ø€ ÷ Bñ B¡*ñ Br   c                ó<   € V P                   P                  ! V3/ VB # )z‚
Forwards all arguments to the image processor's `postprocess` method.
Refer to the original method's docstring for more details.
)rC   Úpostprocess)rB   rI   rE   s   &&,r   rb   ÚJanusProcessor.postprocesss   s    € ð
 ×#Ñ#×/Ò/°ÑA¸&ÑAÐAr   c                ó  € Ve   VR8X  d   V P                   ! V3RV/VB # VR8X  d6   \        VP                  4       4      pV P                  VRR7      pVR,          # \	        V P
                  P                   RV R24      h)	a”  
Post-process the output of a multimodal model to return the requested modality output.
If the model cannot generated the requested modality, an error will be raised.

Args:
    generated_outputs (`torch.Tensor` or `np.ndarray`):
        The output of the model `generate` function. The output is expected to be a tensor of shape `(batch_size, sequence_length)`
        or `(sequence_length,)`.
    skip_special_tokens (`bool`, *optional*, defaults to `True`):
        Whether or not to remove special tokens in the output. Argument passed to the tokenizer's `batch_decode` method.
    generation_mode (`str`, *optional*):
        Generation mode indicated which modality to output and can be one of `["text", "image", "audio"]`.
    **kwargs:
        Additional arguments to be passed to the tokenizer's `batch_decode method`.

Returns:
    `list[Union[str, PIL.Image.Image]]`: The decoded text or generated image.
r*   Úskip_special_tokensrN   zPIL.Image.Image)r,   Úpixel_valuesz# got an unexpected generation_mode=z.. Supported options are only `text` and `image)Úpost_process_image_text_to_textrK   Úfloatrb   Ú
ValueErrorrF   r   )rB   Úgenerated_outputsre   r   rE   rI   s   &&&&, r   Úpost_process_multimodal_outputÚ-JanusProcessor.post_process_multimodal_outputz   s¬   € ð* Ò" o¸Ô&?Ø×7Ò7Ø!ñØ7JðØNTñð ð  Ô'Ü $Ð%6×%<Ñ%<Ó%>Ó ?ÐØ×%Ñ%Ð&7ÐHYÐ%ÓZˆFØ˜.Õ)Ð)ô Ø—>‘>×*Ñ*Ð+Ð+NÈÐN_ð  `Nð  Oóð r   )r?   r=   r;   r6   r5   )NFi@  )NN)TN)r   r   r   r   r%   Úvalid_processor_kwargsrA   r   rS   r^   rb   rk   r    r!   Ú__classcell__)rF   r   s   @@r   r2   r2   5   sP   ù‡ € à1Ð÷Rõ Rð. ÷ô ó ð÷<ð ÷Bð B÷"ô "r   r2   N)r   Úfeature_extraction_utilsr   Úimage_utilsr   Úprocessing_utilsr   r   r   r   Útokenization_utils_baser	   r
   Úutilsr   r   Ú
get_loggerr   ÚloggerrR   r   r%   r2   Ú__all__r   r   r   Ú<module>rw      s�   ðñõ 5Ý %ß TÓ Tß Cß ,ð 
×	Ò	˜HÓ	%€ðNð ô�j¨õ ôÐ+°5õ ð ôf�^ó fó ðfðR Ð
‚r   