Team Ai
Apppublic

diffusers/stable-diffusion-xl-inpainting

sourceHugging Faceupdated 9mo agoView on Hugging Face
509likes
app.cpython-310.pyc72 linesDownload Raw Back to __pycache__
1o

2N��d��@s�ddlZddlZddlmZmZddlZddlmZmZm	Z	ej3dejdd�Zej4deejdd	��
d5�Zdedefd
d�ZdNdd�ZdZejed�Ze���Ze�ed��e����pe����Ze����e����ejdddddd�jdd �Zejd!d"�jd#d$d%��ejd&d#d'd(�ZWd�n1s�wYejd!d"�jd#d$d%��&ej ddd)d*d+d,�Z!ej dd-d.d*d/d,�Z"ej dd0dd1d2d,�Z#Wd�n1s�wYejd!d"�jd#d$d%��gd3�Z$ej%e$dd4�Z&e�'d5�jd#d6d#d7�Z(Wd�n	1�swYWd�n	1�swYe���@ejd8d9d:�jdd �Z)ejd;d"��ejed#d<�Z*ejed#d<�Z+ej'd=d>d#d?�Z,Wd�n	1�sPwYWd�n	1�s`wYWd�n	1�spwYe(j-eeee!e"e#e&ge)e*e+e,gd@�e,j-dgge	dA�ej.dBgdCgdDgdEgdFgdGgdHgdIgdJgdKgg6eegd#dL�e�dM�Wd�n	1�s�wYWd�n	1�s�wYWd�n	1�s�wYe�/�dS)O�N)�AutoPipelineForInpainting�UNet2DConditionModel)�community_icon_html�loading_icon_html�share_jszvalhalla/sdxl-inpaint-ema�(d5593e75323fa2a5285ebe02c1aba504a695bbf7)�torch_dtype�revision�(stabilityai/stable-diffusion-xl-base-1.0�fp16)�unetr�variant�cuda�	file_path�returncCs<t|ddd��
}|��}Wd�|S1swY|S)z$read the content of target file7    �rzutf-8)�encodingN)�open�read)r�f�content�r�3/home/patrick/stable-diffusion-xl-inpainting/app.py�read_contents89��r��@���?�EulerDiscreteSchedulercCs�|�d�d}i}t|�d��dkrd|d<t|�d��dkr#d|d<tt|�}|jdd10di|��t_|d�d
��d�}|d�d
��d�}	t|||	|t	|�|d�}11|12j13dtjdd�tjdd�tjdd�fS)N�-r�T�14use_karras�zsde-dpmsolver++�algorithm_typer15�	subfolder�	scheduler�image�RGB)�r(�mask)�promptr&�16mask_image�guidance_scale�num_inference_steps�strength��visible)r17)
�split�len�getattr�	diffusers�from_pretrained�piper%�convert�resize�int�images�gr�update)�dictr*r,�stepsr.r%�scheduler_class_name�18add_kwargs�19init_imager)�outputrrr�predicts20*rCa�21.container {max-width: 1150px;margin: auto;padding-top: 1.5rem}22#image_upload{min-height:400px}23#image_upload [data-testid="image"], #image_upload [data-testid="image"] > div{min-height: 400px}24#mask_radio .gr-form{background:transparent; border: none}25#word_mask{margin-top: .75em !important}26#word_mask textarea:disabled{opacity: 0.3}27.footer {margin-bottom: 45px;margin-top: 35px;text-align: center;border-bottom: 1px solid #e5e5e5}28.footer>p {font-size: .8rem; display: inline-block; padding: 0 10px;transform: translateY(10px);background: white}29.dark .footer {border-color: #303030}30.dark .footer>p {background: #0b0f19}31.acknowledgments h4{margin: 1.25em 0 .25em 0;font-weight: bold;font-size: 115%}32#image_upload .touch-none{display: flex}33@keyframes spin {34    from {35        transform: rotate(0deg);36    }37    to {38        transform: rotate(360deg);39    }40}41#share-btn-container {42    display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;43}44#share-btn {45    all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;46}47#share-btn * {48    all: unset;49}50#share-btn-container div:nth-child(-n+2){51    width: auto !important;52    min-height: 0px !important;53}54#share-btn-container .wrap {55    display: none !important;56}57)�csszheader.html�upload�sketch�image_upload�pil�Upload)�source�tool�elem_id�type�labeli�)�heightzprompt-container)rLFT)�mobile_collapse�equal_heightz6Your prompt (what you want in place of what is erased)z58input-text)�placeholder�59show_labelrLg4@g�������?r,)�value�minimum�maximum�steprN�60�2r>gg�������?r.)�DEISMultistepScheduler�HeunDiscreteSchedulerr�DPMSolverMultistepSchedulerz"DPMSolverMultistepScheduler-Karrasz&DPMSolverMultistepScheduler-Karras-SDE)�choicesrTzInpaint!)FTTF)�margin�rounded�61full_width�Outputz62output-img)rNrLzshare-btn-containerr/zShare to communityz	share-btn)rLr0)�fn�inputs�outputs)�_jsz./imgs/aaa (8).pngz./imgs/download (1).jpegz./imgs/0_oE0mLhfhtS_3Nfm2.pngz%./imgs/02_HubertyBlog-1-1024x1024.jpgz(./imgs/jdn_jacques_de_nuce-1024x1024.jpgz+./imgs/c4ca473acde04280d44128ad8ee09e8a.jpgz,./imgs/canam-electric-motorcycles-scaled.jpgz,./imgs/e8717ce80b394d1b9a610d04a1decd3a.jpegz4./imgs/Nature___Mountains_Big_Mountain_018453_31.jpgz7./imgs/Multible-sharing-room_ccexpress-2-1024x1024.jpeg)�examplesrbrc�cache_examplesu&63                    <div class="footer">64                        <p>Model by <a href="https://huggingface.co/diffusers" style="text-decoration: underline;" target="_blank">Diffusers</a> - Gradio Demo by 🤗 Hugging Face65                        </p>66                    </div>67                )rrrrr)0�gradior;�torchr4rr�	share_btnrrrr5�float16r�tor6�strrrCrD�Blocks�image_blocks�demo�HTML�Group�Box�Row�Column�Image�styler&�Textboxr*�Numberr,r>r.�68schedulers�Dropdownr%�Button�btn�	image_out�community_icon�loading_icon�share_button�click�Examples�launchrrrr�<module>s�69'70��71����72�����$��������=