o
    Yi$                     @   s  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	ej
ejedZej	ej
ejed	Zej	ej
ejed
ZejdejjeddZejdejddddZejdejjedejddddZejdejjedejddddZejdejjedejdddZejdejjedejddddZ ej!dejdddZ"ejdejddejdddZ#ej$d d!ej%ed"eegej&ej'j(dd#d$ej)j*ej+j,dd%d&d'd(dd)d*id+d,d-ej$d.d!ej%ed/eegej&ej'j(dd%d0d,d-ej$d1d!ej%ed2eegej&dd3d%d4d,d-ej$d5d!ej%ed6egej&dd3d%d4d,d-ej$d7d!ej%ed8e gej&dd3d%d4d,d-ej$d9d!ej%d:d;e"e#gej&dd3d%d&d<d,d-gZ-e.ej$ e/d=< ej0ee1 d>e-d?Z2d@dA Z3ej4j5dBdC Z6dS )Dz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_imageZMASK_MODE_BACKGROUNDgQ?)Z	mask_modeZmask_dilation)r	   configZMASK_MODE_USER_PROVIDED)r	   r
   r   ZCONTROL_TYPE_SCRIBBLEF)Zcontrol_typeZ enable_control_image_computationzglowing style)Zstyle_descriptionSUBJECT_TYPE_PRODUCT/A product logo that is a multi-colored letter GZsubject_typeZsubject_descriptionz*gs://genai-sdk-tests/inputs/images/dog.jpg)Zgcs_uriz0gs://genai-sdk-tests/inputs/images/cyberpunk.jpgzcyberpunk styleZtest_edit_mask_inpaint_insertz&only supported in the Vertex AI clientSunlight and clear weatherhuman      .@T
image/jpegP       Z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_qualityZ
base_stepsadd_watermarklabelsmodelpromptZreference_imagesr   )nameexception_if_mldev
parametersZ+test_edit_mask_inpaint_insert_user_providedzChange the colors)r   r   r   Ztest_edit_control_user_providedz4Change the colors aligning with the scribble map [2]z9:16)r   aspect_ratior   Z-test_edit_style_reference_image_customizationz`Generate an image in glowing style [1] based on the following caption: A church in the mountain.Z%test_edit_subject_image_customizationz\Generate an image containing a mug with the product logo [1] visible on the side of the mug.Z#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)fileZglobals_for_fileZtest_methodr)   c              	   C   sX   t tj tjddtjjtdtj	dddd W d    d S 1 s%w   Y  d S )Nr   ZREFERENCE_TYPE_SUBJECTr   r   r   r   )r	   Zreference_typer
   r   )
pytestZraisespydanticZValidationErrorr   SubjectReferenceImageImage	from_fileIMAGE_FILE_PATHSubjectReferenceConfig)client r3   c/home/kim/smarthome/.venv/lib/python3.10/site-packages/google/genai/tests/models/test_edit_image.py"test_setting_reference_type_raises   s   "r5   c                    s   t | t6 | 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	d
I d H }|jd jjs5J W d    d S 1 s@w   Y  d S )Nr   r   r   r   FTr   r   )r   r   r   r   r   r   r   r   r   r   r    r"   r   )r   r&   
ValueErrorZaiomodelsr   CAPABILITY_MODEL_NAMEraw_ref_imagemask_ref_imager   EditImageConfigEditModeEDIT_MODE_INPAINT_INSERTIONSafetyFilterLevelBLOCK_MEDIUM_AND_ABOVEPersonGeneration
DONT_ALLOWZgenerated_imagesimageZimage_bytes)r2   responser3   r3   r4   #test_edit_mask_inpaint_insert_async   s,   "rD   )7__doc__osr,   r+    r   r   r8   pathabspathjoindirname__file__r0   ZMASK_FILE_PATHZBRIDGE_IMAGE_FILE_PATHZRawReferenceImager.   r/   r9   ZMaskReferenceImageZMaskReferenceConfigr:   Zmask_ref_image_user_providedZControlReferenceImageZControlReferenceConfigZcontrol_ref_imageZStyleReferenceImageZStyleReferenceConfigZstyle_ref_image_customizationr-   r1   Zsubject_ref_image_customizationZContentReferenceImageZdog_content_ref_imageZcyberpunk_style_ref_imageZTestTableItemZ_EditImageParametersr;   r<   r=   r>   r?   r@   rA   r)   list__annotations__setupglobalsZ
pytestmarkr5   markZasynciorD   r3   r3   r3   r4   <module>   sd  	
	n