Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,12 @@ from PIL import Image, ImageOps
|
|
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")
|
9 |
|
10 |
-
|
11 |
def get_select_index(evt: gr.SelectData):
|
12 |
print(evt)
|
13 |
return evt.index
|
14 |
|
15 |
-
|
16 |
def squarify_image(img):
|
17 |
if(img.height > img.width): bg_size = img.height
|
18 |
else: bg_size = img.width
|
@@ -21,7 +21,7 @@ def squarify_image(img):
|
|
21 |
|
22 |
return bg
|
23 |
|
24 |
-
|
25 |
def divisible_by_8(image):
|
26 |
width, height = image.size
|
27 |
|
@@ -34,13 +34,13 @@ def divisible_by_8(image):
|
|
34 |
|
35 |
return resized_image
|
36 |
|
37 |
-
|
38 |
def restore_version(index, versions):
|
39 |
print('restore version:', index)
|
40 |
final_dict = {'background': versions[index][0], 'layers': None, 'composite': versions[index][0]}
|
41 |
return final_dict
|
42 |
|
43 |
-
|
44 |
def generate(image_editor, prompt, neg_prompt, versions):
|
45 |
image = image_editor['background'].convert('RGB')
|
46 |
|
|
|
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")
|
9 |
|
10 |
+
@spaces.GPU()
|
11 |
def get_select_index(evt: gr.SelectData):
|
12 |
print(evt)
|
13 |
return evt.index
|
14 |
|
15 |
+
@spaces.GPU()
|
16 |
def squarify_image(img):
|
17 |
if(img.height > img.width): bg_size = img.height
|
18 |
else: bg_size = img.width
|
|
|
21 |
|
22 |
return bg
|
23 |
|
24 |
+
@spaces.GPU()
|
25 |
def divisible_by_8(image):
|
26 |
width, height = image.size
|
27 |
|
|
|
34 |
|
35 |
return resized_image
|
36 |
|
37 |
+
@spaces.GPU()
|
38 |
def restore_version(index, versions):
|
39 |
print('restore version:', index)
|
40 |
final_dict = {'background': versions[index][0], 'layers': None, 'composite': versions[index][0]}
|
41 |
return final_dict
|
42 |
|
43 |
+
@spaces.GPU()
|
44 |
def generate(image_editor, prompt, neg_prompt, versions):
|
45 |
image = image_editor['background'].convert('RGB')
|
46 |
|