Spaces:
Runtime error
Runtime error
add url tab logic
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ from transformers import (
|
|
13 |
from diffusers import DDPMScheduler,AutoencoderKL
|
14 |
from typing import List
|
15 |
import ast
|
|
|
16 |
|
17 |
import torch
|
18 |
import os
|
@@ -252,10 +253,7 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
252 |
# return images[0], mask_gray
|
253 |
# Function to handle image selection from the gallery
|
254 |
def select_image(images, urls, evt: gr.SelectData):
|
255 |
-
|
256 |
-
print(type(urls))
|
257 |
urls = ast.literal_eval(urls)
|
258 |
-
print(f"URL of image is {urls[evt.index]}")
|
259 |
return images[evt.index][0], urls[evt.index]
|
260 |
|
261 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
@@ -274,7 +272,7 @@ for ex_human in human_list_path:
|
|
274 |
|
275 |
def open_link(link):
|
276 |
print(f"link here is {link}")
|
277 |
-
|
278 |
##default human
|
279 |
|
280 |
|
@@ -323,6 +321,6 @@ with image_blocks as demo:
|
|
323 |
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, price_display, url_display])
|
324 |
image_gallery.select(select_image, [image_gallery, url_display], [garm_img, buy_link])
|
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 |
-
buy_button.click(fn=open_link, inputs=buy_link
|
327 |
|
328 |
image_blocks.launch()
|
|
|
13 |
from diffusers import DDPMScheduler,AutoencoderKL
|
14 |
from typing import List
|
15 |
import ast
|
16 |
+
import webbrowser
|
17 |
|
18 |
import torch
|
19 |
import os
|
|
|
253 |
# return images[0], mask_gray
|
254 |
# Function to handle image selection from the gallery
|
255 |
def select_image(images, urls, evt: gr.SelectData):
|
|
|
|
|
256 |
urls = ast.literal_eval(urls)
|
|
|
257 |
return images[evt.index][0], urls[evt.index]
|
258 |
|
259 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
|
|
272 |
|
273 |
def open_link(link):
|
274 |
print(f"link here is {link}")
|
275 |
+
webbrowser.open_new_tab(link)
|
276 |
##default human
|
277 |
|
278 |
|
|
|
321 |
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, price_display, url_display])
|
322 |
image_gallery.select(select_image, [image_gallery, url_display], [garm_img, buy_link])
|
323 |
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')
|
324 |
+
buy_button.click(fn=open_link, inputs=buy_link)
|
325 |
|
326 |
image_blocks.launch()
|