o
    TÒ
j,  ã                   @   s\   d dl Z d dlZd dlZd dlmZ d dlmZ dZdZdd„ Z	e
dkr,e e	ƒ ¡ dS dS )	é    N)ÚImage)ÚDiffusionPipelinez!black-forest-labs/FLUX.2-klein-9BÚcudac               
   C   s"  zvt tjƒdk rtdƒ‚tjd } tjd }tj | ¡s#td| › ƒ‚tj	t
tjdd t¡}| ¡  | ¡  t | ¡ d¡}| d	¡}d
}|||ddddtjtd d¡djd }tj |¡}|rjtj|dd | |¡ td|ƒ W dS  ty } ztd|› ƒ W Y d }~dS d }~ww )Né   uw   ìž…ë ¥ íŒŒì¼ê³¼ ì¶œë ¥ íŒŒì¼ì„ íŒŒë¼ë©”í„°ë¡œ ì „ë‹¬í•˜ì„¸ìš”. ì˜ˆ: python3 flux2_klein_9b.py test1.png output1.pngé   é   u*   ìž…ë ¥ íŒŒì¼ì„ ì°¾ì„ ìˆ˜ ì—†ìŠµë‹ˆë‹¤: T)Útorch_dtypeÚlow_cpu_mem_usageÚRGB)é   r   aK  A highly detailed, realistic fashion catalog product photo of a complete clothing item. Front-view, perfectly symmetrical, fully visible from collar to bottom hem with complete sleeves. Natural fabric folds, preserving the exact original color, texture, and pattern. Plain white studio background, professional lighting, uncropped.r   g      @é   )ÚdeviceiÒ  )ÚimageÚpromptÚheightÚwidthÚguidance_scaleÚnum_inference_stepsÚ	generatorr   )Úexist_okzSaved:zERROR: )ÚlenÚsysÚargvÚ
ValueErrorÚosÚpathÚisfileÚFileNotFoundErrorr   Úfrom_pretrainedÚMODEL_IDÚtorchÚfloat16ÚtoÚDEVICEÚenable_attention_slicingÚenable_model_cpu_offloadr   ÚopenÚconvertÚresizeÚ	GeneratorÚmanual_seedÚimagesÚdirnameÚmakedirsÚsaveÚprintÚ	Exception)Ú
input_pathÚoutput_pathÚpiper   r   ÚresultÚ
output_dirÚexc© r7   ú)htdocs/OOTD2/inpainting/flux2_klein_9b.pyÚmain   sT   

ýü
ÿ
ùø

€þr9   Ú__main__)r   r   r    ÚPILr   Ú	diffusersr   r   r#   r9   Ú__name__Úexitr7   r7   r7   r8   Ú<module>   s   Dÿ