
    q[i$                     	   U d Z ddlZddlZddlZddlmZ ddlmZ dZej                  j                  ej                  j                  ej                  j                  e      d            Zej                  j                  ej                  j                  ej                  j                  e      d	            Zej                  j                  ej                  j                  ej                  j                  e      d
            Z ej                   dej"                  j%                  e            Z ej(                  d ej*                  dd            Z ej(                  dej"                  j%                  e       ej*                  dd            Z ej0                  dej"                  j%                  e       ej2                  dd            Z ej6                  dej"                  j%                  e       ej8                  d            Z ej<                  dej"                  j%                  e       ej>                  dd            Z  ejB                  d ej"                  d            Z" ej6                  d ej"                  d       ej8                  d            Z# ejH                  d d! ejJ                  ed"eeg ejL                  ejN                  jP                  dd#d$ejR                  jT                  ejV                  jX                  dd%d&d'd(dd)d*i+      ,      -       ejH                  d.d! ejJ                  ed/eeg ejL                  ejN                  jP                  dd%0      ,      -       ejH                  d1d! ejJ                  ed2eeg ejL                  dd3d%4      ,      -       ejH                  d5d! ejJ                  ed6eg ejL                  dd3d%4      ,      -       ejH                  d7d! ejJ                  ed8e g ejL                  dd3d%4      ,      -       ejH                  d9d! ejJ                  d:d;e"e#g ejL                  dd3d%d&<      ,      -      gZ-e.ejH                     e/d=<    ej`                  e e1       d>e-?      Z2d@ Z3ejh                  jj                  dA        Z6y)BzTests for edit_image.    N   )types   )pytest_helperzimagen-3.0-capability-001z../data/google.pngz../data/checkerboard.pngz../data/bridge1.png   location)reference_idreference_imageMASK_MODE_BACKGROUNDgQ?)	mask_modemask_dilation)r
   configMASK_MODE_USER_PROVIDED)r
   r   r   CONTROL_TYPE_SCRIBBLEF)control_type enable_control_image_computationzglowing style)style_descriptionSUBJECT_TYPE_PRODUCT/A product logo that is a multi-colored letter Gsubject_typesubject_descriptionz*gs://genai-sdk-tests/inputs/images/dog.jpg)gcs_uriz0gs://genai-sdk-tests/inputs/images/cyberpunk.jpgzcyberpunk styletest_edit_mask_inpaint_insertz&only supported in the Vertex AI clientSunlight and clear weatherhuman      .@T
image/jpegP       imagen_label_key
edit_image)	edit_modenumber_of_imagesnegative_promptguidance_scalesafety_filter_levelperson_generationinclude_safety_attributesinclude_rai_reasonoutput_mime_typeoutput_compression_quality
base_stepsadd_watermarklabelsmodelpromptreference_imagesr   )nameexception_if_mldev
parameters+test_edit_mask_inpaint_insert_user_providedzChange the colors)r$   r%   r+   test_edit_control_user_providedz4Change the colors aligning with the scribble map [2]z9:16)r%   aspect_ratior+   -test_edit_style_reference_image_customizationz`Generate an image in glowing style [1] based on the following caption: A church in the mountain.%test_edit_subject_image_customizationz\Generate an image containing a mug with the product logo [1] visible on the side of the mug.#test_edit_content_image_ingredientszimagen-4.0-ingredients-previewzxDog in [1] sleeping on the ground at the bottom of the image with the cyberpunk city landscape in [2] in the background.)r%   r:   r+   r,   
test_tablezmodels.edit_image)fileglobals_for_filetest_methodr>   c           
         t        j                  t        j                        5  t	        j
                  ddt        j                  j                  t              t	        j                  dd             d d d        y # 1 sw Y   y xY w)Nr   REFERENCE_TYPE_SUBJECTr   r   r   r   )r
   reference_typer   r   )
pytestraisespydanticValidationErrorr   SubjectReferenceImageImage	from_fileIMAGE_FILE_PATHSubjectReferenceConfig)clients    b/mnt/data/GridWatch/venv/lib/python3.12/site-packages/google/genai/tests/models/test_edit_image.py"test_setting_reference_type_raisesrP      sf    }}X--. 	/---G++/A
  s   AA>>Bc                   K   t        j                  | t              5  | j                  j                  j                  t        dt        t        gt        j                  t        j                  j                  dddt        j                  j                  t        j                  j                   ddddd	      
       d {   }|j"                  d   j$                  j&                  sJ 	 d d d        y 7 3# 1 sw Y   y xY ww)Nr   r   r   r   FTr   r    )r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r/   r1   r   )r   r6   
ValueErroraiomodelsr#   CAPABILITY_MODEL_NAMEraw_ref_imagemask_ref_imager   EditImageConfigEditModeEDIT_MODE_INPAINT_INSERTIONSafetyFilterLevelBLOCK_MEDIUM_AND_ABOVEPersonGeneration
DONT_ALLOWgenerated_imagesimageimage_bytes)rN   responses     rO   #test_edit_mask_inpaint_insert_asyncrc      s     ''
; :ZZ&&11#+'8$$nn@@ $ % 7 7 N N#44??&+#)')
	 2  H( $$Q'--9999+: :: :s/   D B!C4>C2?)C4)	D 2C44C=9D )7__doc__osrG   rE    r   r   rU   pathabspathjoindirname__file__rL   MASK_FILE_PATHBRIDGE_IMAGE_FILE_PATHRawReferenceImagerJ   rK   rV   MaskReferenceImageMaskReferenceConfigrW   mask_ref_image_user_providedControlReferenceImageControlReferenceConfigcontrol_ref_imageStyleReferenceImageStyleReferenceConfigstyle_ref_image_customizationrI   rM   subject_ref_image_customizationContentReferenceImagedog_content_ref_imagecyberpunk_style_ref_imageTestTableItem_EditImageParametersrX   rY   rZ   r[   r\   r]   r^   r>   list__annotations__setupglobals
pytestmarkrP   markasynciorc        rO   <module>r      s  "  	    3 ''//GGLL*,@A GGLL*,FG GGLL*,AB  (''KK))?)C
 *))$5$$(  8u77KK))>)B$5$$+   0E//KK))>)B'5'',).  !: 9 9KK))?)C%5%%)!  #>%"="=KK))?)C'5''+M#  433EKK<  6E55EKKB &5%%+   M,C-5--'/+^<(5((..DD!" !(#$)$;$;$R$R"'"8"8"C"C*/#'!-+-#*L9	
4  M:C-5--'&+-IJ(5((..DD!"#'		

  M.C-5--'I+->?(5((!"##'		
  M<C-5--'6 <<(5((!"##'
"  M4C-5--'3 >>(5((!"##'
"  M2C-5--2O 45NO(5((!"##'!-	
ul1
D,,- l\ !]  	Y#	
  : :r   