Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
from diffusers import AutoPipelineForInpainting, AutoencoderKL
|
4 |
import torch
|
5 |
from PIL import Image, ImageOps
|
|
|
6 |
|
7 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
8 |
pipeline = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")
|
@@ -43,6 +44,7 @@ def clear_all():
|
|
43 |
|
44 |
@spaces.GPU()
|
45 |
def generate(image_editor, prompt, neg_prompt, versions):
|
|
|
46 |
image = image_editor['background'].convert('RGB')
|
47 |
|
48 |
# Resize image
|
@@ -87,6 +89,9 @@ def generate(image_editor, prompt, neg_prompt, versions):
|
|
87 |
else:
|
88 |
final_gallery = versions
|
89 |
final_gallery.append(final_image)
|
|
|
|
|
|
|
90 |
|
91 |
return final_dict, gr.Gallery(value=final_gallery, visible=True), gr.update(visible=True), gr.update(visible=True)
|
92 |
|
|
|
3 |
from diffusers import AutoPipelineForInpainting, AutoencoderKL
|
4 |
import torch
|
5 |
from PIL import Image, ImageOps
|
6 |
+
import time
|
7 |
|
8 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
9 |
pipeline = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")
|
|
|
44 |
|
45 |
@spaces.GPU()
|
46 |
def generate(image_editor, prompt, neg_prompt, versions):
|
47 |
+
start = time.time()
|
48 |
image = image_editor['background'].convert('RGB')
|
49 |
|
50 |
# Resize image
|
|
|
89 |
else:
|
90 |
final_gallery = versions
|
91 |
final_gallery.append(final_image)
|
92 |
+
|
93 |
+
end = time.time()
|
94 |
+
print('time:', end - start)
|
95 |
|
96 |
return final_dict, gr.Gallery(value=final_gallery, visible=True), gr.update(visible=True), gr.update(visible=True)
|
97 |
|