cmahima commited on
Commit
e62ce10
1 Parent(s): 67e2e24

make changes

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- def select_image(index, gallery_images):
315
- if index is not None and index < len(gallery_images):
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