Spaces:
Running
on
Zero
Running
on
Zero
make changes
Browse files
app.py
CHANGED
@@ -13,6 +13,9 @@ from transformers import (
|
|
13 |
from diffusers import DDPMScheduler,AutoencoderKL
|
14 |
from typing import List
|
15 |
|
|
|
|
|
|
|
16 |
import torch
|
17 |
import os
|
18 |
from transformers import AutoTokenizer
|
@@ -249,6 +252,11 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
249 |
else:
|
250 |
return images[0], mask_gray
|
251 |
# return images[0], mask_gray
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
254 |
garm_list_path = [os.path.join(example_path,"cloth",garm) for garm in garm_list]
|
@@ -311,11 +319,8 @@ with image_blocks as demo:
|
|
311 |
|
312 |
|
313 |
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, price_display, url_display])
|
314 |
-
|
315 |
-
|
316 |
-
return gallery_images[index]
|
317 |
-
return None
|
318 |
-
image_gallery.select(fn=select_image, inputs=[gr.Slider(0, 9), image_gallery], outputs=garm_img)
|
319 |
|
320 |
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, prompt, is_checked,is_checked_crop, denoise_steps, seed], outputs=[image_out,masked_img], api_name='tryon')
|
321 |
|
|
|
13 |
from diffusers import DDPMScheduler,AutoencoderKL
|
14 |
from typing import List
|
15 |
|
16 |
+
import requests
|
17 |
+
from io import BytesIO
|
18 |
+
|
19 |
import torch
|
20 |
import os
|
21 |
from transformers import AutoTokenizer
|
|
|
252 |
else:
|
253 |
return images[0], mask_gray
|
254 |
# return images[0], mask_gray
|
255 |
+
# Function to handle image selection from the gallery
|
256 |
+
def select_image(image_url):
|
257 |
+
response = requests.get(image_url)
|
258 |
+
image = Image.open(BytesIO(response.content))
|
259 |
+
return image
|
260 |
|
261 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
262 |
garm_list_path = [os.path.join(example_path,"cloth",garm) for garm in garm_list]
|
|
|
319 |
|
320 |
|
321 |
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, price_display, url_display])
|
322 |
+
|
323 |
+
image_gallery.select(fn=select_image, inputs=image_gallery, outputs=garm_img)
|
|
|
|
|
|
|
324 |
|
325 |
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, prompt, is_checked,is_checked_crop, denoise_steps, seed], outputs=[image_out,masked_img], api_name='tryon')
|
326 |
|