+
    œ°³jì   ã                   óÔ   a € R t0 t ^ RIHtHt ^RIHt ^RIHt ^RIH	t	 ^RI
Ht ^RIHtHt ]P                  ! ]4      tRRR	R
RR/t] ^ k  ! R R]RR7      t ! R R]4      tR.tR# )é    )ÚMappingÚSequence)ÚBatchFeature)Ú
ImageInput)ÚUnpack)Úlogging)ÚGemma3ProcessorÚGemma3ProcessorKwargsÚ	dangerouszçNo Dangerous Content: The image shall not contain content that facilitates or encourages activities that could cause real-world harm (e.g., building firearms and explosive devices, promotion of terrorism, instructions for suicide).Úsexualz¸No Sexually Explicit content: The image shall not contain content that depicts explicit or graphic sexual acts (e.g., pornography, erotic nudity, depictions of rape or sexual assault).ÚviolencezâNo Violence/Gore content: The image shall not contain content that depicts shocking, sensational, or gratuitous violence (e.g., excessive blood and gore, gratuitous violence against animals, extreme injury or moment of death).c                   ó@   a € ] tR t^/t o RRR/RRR//tV 3R ltRtV tR	# )
ÚShieldGemma2ProcessorKwargsÚtext_kwargsÚpaddingTÚimages_kwargsÚdo_pan_and_scanFc                ót   <€ V ^8„  d   Qh/ S[ S[,          R,          ;R&   S[S[S[3,          R,          ;R&   # )é   NÚpoliciesÚcustom_policies)r   Ústrr   )ÚformatÚ__classdict__s   "€Úy/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/shieldgemma2/processing_shieldgemma2.pyÚ__annotate__Ú(ShieldGemma2ProcessorKwargs.__annotate__/   s2   ø‡ ‚ Ù‘s�m˜dÕ"Ñ"ñ á™S¡#˜XÕ&¨Õ-Ñ-ò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r   /   s1   ø‡ € ð 	Ø�tð
ð 	Ø˜uð
ð	€I÷ ƒ r   r   F)Útotalc                   óR   a a€ ] tR t^<t oRV 3R lltRV3R lV 3R llltRtVtV ;t# )ÚShieldGemma2Processorc                óZ   <€ \         SV `  ! WW43/ VB  Vf   \        V n        R# WPn        R# )a»  A processor for the ShieldGemma 2 model.

Args:
    image_processor: The image processor to use, typically a `Gemma3ImageProcessor` instance.
    tokenizer: The tokenizer to use, typically a `GemmaTokenizerFast` instance.
    chat_template: The chat template to use with this processor. Typically, this is unset as the processor
        configuration on Hugging Face Hub includes this value already.
    image_seq_length: The number of soft tokens per image. Typically, this is unset as the processor
        configuration on Hugging Face Hub includes this value already.
    policy_definitions: A mapping from policy name to its description in text used as the default policies to
        classify images against. The policy descriptions are included in the text of the prompts generated by
        this processor. Typically, this is unset as the processor configuration on Hugging Face Hub includes
        the base policies ShieldGemma was trained on.
N)ÚsuperÚ__init__ÚDEFAULT_SHIELDGEMMA2_POLICIESÚpolicy_definitions)ÚselfÚimage_processorÚ	tokenizerÚchat_templateÚimage_seq_lengthr/   ÚkwargsÚ	__class__s   &&&&&&,€r   r-   ÚShieldGemma2Processor.__init__=   s.   ø€ ô" 	‰Ò˜°]Ñ_ÐX^Ò_ØÒ%Ü&CˆDÖ#à&8Ö#r   c                óJ   <€ V ^8„  d   QhRS[ R,          RS[S[,          RS[/# )r   ÚimagesNr5   Úreturn)r   r   r   r   )r   r   s   "€r   r   Ú"ShieldGemma2Processor.__annotate__T   s>   ø€ ÷ gMñ gMá˜TÕ!ðgMñ Ñ4Õ5ð	gMñ
 
ñgMr   c                óP  <€ V'       g   \        R4      h\        V\        4      '       g   V.pV P                  '       g   \        R4      hVP	                  R/ 4      pRV9   d   VP                  R4      VR&   VP	                  R/ 4      pVP                  R4      RJ d   \        P                  R4       R	VR&   VP	                  R
/ 4      pRV9  d+   VP                  RR4      VR&   VP                  RR4      VR&   / V P                  CVP                  R/ 4      CpVP                  R4      ;pf   \        VP                  4       4      p. p	. p
V F­  p\        V\        4      '       g   V.pM(\        V4      ^8”  d   \        R\        V4       R24      hV Fb  pV'       d&   V	P                  RRRRR/RRRW|,          /./.4       M!V	P                  RRRRRRW|,          /./.4       V
P                  V4       Kd  	  K¯  	  V P                  V	R	R7      p\        SV `@  ! RRV
RV/VB # )a
  Generates a batch of inputs from the provided images.

ShieldGemma was trained to classify image content for policy compliance using a specific prompt construction.
This processor generates a batch of such prompts from the provided images by:

1.  Creating a list of conversations, one for each `<image, policy>` pair;
2.  Converting these conversations to text using `self.apply_chat_template()`; and
3.  Encoding the conversations and images using the same techniques as `Gemma3Processor`.

Args:
    images: A single image or a list of images to include in the batch.
    text: Not supported.
    videos: Not supported.
    audio: Not supported.
    kwargs: An optional dictionary of keyword arguments to configure the
        processor. Possible values include:

        *   `custom_policies`: Additional policy definitions that augment the `self.policy_definitions` passed
            into the constructor. Note that `custom_policies` that share a key with `self.policy_definitions`
            will override the policy description
        *   `policies`: (Optional) a list of keys in the joint `self.policy_definitions | custom_policies`
            dictionary of specific interest for the provided images. If empty or None, prompts will be
            generated for every key in the joint dictionary.

Returns:
    A `BatchFeature` containing `input_ids`, `pixel_values`, etc. where each Tensor is of shape
    `(len(images) * len(policies), )`, and the order within the batch will be
    img1_policy1, ... img1_policyN, ... imgM_policyN.
z&ShieldGemma 2 needs images to classifyz:ShieldGemma 2 requires the use of a specific chat templateÚcommon_kwargsÚreturn_tensorsr   r   Tz+ShieldGemma2 does not support pan and scan.Fr   r   Úpadding_sideÚleftr   r   z>ShieldGemma can process at most one image per sample, but got z imagesÚroleÚuserÚcontentÚtypeÚimageÚtext)Útokenizer9   r   )Ú
ValueErrorÚ
isinstancer   r3   Ú
setdefaultÚpopÚgetÚloggerÚwarning_oncer/   ÚlistÚkeysÚlenÚappendÚapply_chat_templater,   Ú__call__)r0   r9   rF   r5   r=   r   r   r/   r   ÚmessagesÚexpanded_imagesÚimgÚpolicyr6   s   &&&,         €r   rT   ÚShieldGemma2Processor.__call__T   se  ø€ ÷F ÜÐEÓFÐFÜ˜F¤H×-Ò-Ø�XˆFà×!×!Ð!ÜÐYÓZÐZà×)Ñ)¨/¸2Ó>ˆØ˜vÔ%Ø.4¯j©jÐ9IÓ.JˆMÐ*Ñ+ð ×)Ñ)¨/¸2Ó>ˆØ×ÑÐ.Ó/°4Ó7Ü×ÑÐ MÔNØ/4ˆMÐ+Ñ,ð ×'Ñ'¨°rÓ:ˆØ˜KÔ'Ø%+§Z¡Z°	¸4Ó%@ˆK˜	Ñ"Ø*0¯*©*°^ÀVÓ*LˆK˜Ñ'ð1
Ø×%Ñ%ð1
à�j‰jÐ*¨BÓ/ð1
Ðð
 Ÿ
™
 :Ó.Ð.ˆHÒ7ÜÐ.×3Ñ3Ó5Ó6ˆHð ˆØˆÛˆCÜ˜c¤4×(Ò(Ø�e‘Ü�S“˜A”Ü Ð#aÔbeÐfiÓbjÐakÐkrÐ!sÓtÐtã"�ßØ—O‘Oð !'¨Ø )Ø%+¨WÐ$5Ø%+¨V°VÐ=OÕ=WÐ$Xð,"ððõ
ð —O‘Oð !'¨Ø )Ø%+¨V°VÐ=OÕ=WÐ$Xð,"ððô	ð  ×&Ñ& sÖ+ó1 #ñ ð@ ×'Ñ'¨¸5Ð'ÓAˆÜ‰wÒÑL ÐL¸TÐLÀVÑLÐLr   )r/   )Né   N)NN)	r    r!   r"   r#   r-   rT   r&   r'   Ú__classcell__)r6   r   s   @@r   r*   r*   <   s   ù‡ € ÷9÷.gM÷ gMõ gMr   r*   c                ób   € V ^8„  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r   r.   )Ú__conditional_annotations__r   r   )r   s   "r   r   r      s'   € × -Ñ -÷ò œw¤s¬C xÕ0ñ ò .r   N)r]   Úcollections.abcr   r   Úfeature_extraction_utilsr   Úimage_utilsr   Úprocessing_utilsr   Úutilsr   Úgemma3.processing_gemma3r	   r
   Ú
get_loggerr    rM   r.   r   r*   Ú__all__r   )r]   s   @r   Ú<module>rf      s„   øð÷ .Ô -å 4Ý %Ý &Ý ß Mð 
×	Ò	˜HÓ	%€ð ð	1ð
 ð	:ð ð	/ð4Ð ó ô*
Ð"7¸uõ 
ôM˜Oô MðD #Ð
#‚r   