Spaces:
Runtime error
Runtime error
change app.py
Browse files
app.py
CHANGED
@@ -254,7 +254,7 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
254 |
# return images[0], mask_gray
|
255 |
# Function to handle image selection from the gallery
|
256 |
def select_image(images, urls, evt: gr.SelectData):
|
257 |
-
print(urls)
|
258 |
return images[evt.index][0], urls[evt.index]
|
259 |
|
260 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
@@ -271,7 +271,9 @@ for ex_human in human_list_path:
|
|
271 |
ex_dict['composite'] = None
|
272 |
human_ex_list.append(ex_dict)
|
273 |
|
274 |
-
|
|
|
|
|
275 |
##default human
|
276 |
|
277 |
|
@@ -301,17 +303,18 @@ with image_blocks as demo:
|
|
301 |
|
302 |
image_gallery = gr.Gallery(label="Generated images", show_label=True, elem_id="gallery"
|
303 |
, columns=[3], rows=[1], object_fit="contain", height="auto", allow_preview= False)
|
304 |
-
price_display = gr.Textbox(label="
|
305 |
-
url_display = gr.Textbox(label="
|
306 |
with gr.Column():
|
307 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
308 |
masked_img = gr.Image(label="Masked image output", elem_id="masked-img",show_share_button=False)
|
309 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
310 |
image_out = gr.Image(label="Output", elem_id="output-img",show_share_button=False)
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
315 |
with gr.Accordion(label="Advanced Settings", open=False):
|
316 |
with gr.Row():
|
317 |
denoise_steps = gr.Number(label="Denoising Steps", minimum=20, maximum=40, value=30, step=1)
|
@@ -319,8 +322,8 @@ with image_blocks as demo:
|
|
319 |
|
320 |
|
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,
|
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 |
-
|
325 |
|
326 |
image_blocks.launch()
|
|
|
254 |
# return images[0], mask_gray
|
255 |
# Function to handle image selection from the gallery
|
256 |
def select_image(images, urls, evt: gr.SelectData):
|
257 |
+
print(urls[evt.index])
|
258 |
return images[evt.index][0], urls[evt.index]
|
259 |
|
260 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
|
|
271 |
ex_dict['composite'] = None
|
272 |
human_ex_list.append(ex_dict)
|
273 |
|
274 |
+
def open_link(link):
|
275 |
+
print(f"link here is {link}")
|
276 |
+
return f'<script>window.open("{link}", "_blank");</script>'
|
277 |
##default human
|
278 |
|
279 |
|
|
|
303 |
|
304 |
image_gallery = gr.Gallery(label="Generated images", show_label=True, elem_id="gallery"
|
305 |
, columns=[3], rows=[1], object_fit="contain", height="auto", allow_preview= False)
|
306 |
+
price_display = gr.Textbox(label="Prices of Images", interactive=False, visible=False)
|
307 |
+
url_display = gr.Textbox(label="URLs of Images", interactive=False, visible=False)
|
308 |
with gr.Column():
|
309 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
310 |
masked_img = gr.Image(label="Masked image output", elem_id="masked-img",show_share_button=False)
|
311 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
312 |
image_out = gr.Image(label="Output", elem_id="output-img",show_share_button=False)
|
313 |
+
try_button = gr.Button(value="Try-on")
|
314 |
+
buy_link = gr.Textbox(label="URL of Selected Image", interactive=False, visible=False)
|
315 |
+
buy_button = gr.Button(value="Like it? Click to buy")
|
316 |
+
output = gr.HTML()
|
317 |
+
with gr.Column():
|
318 |
with gr.Accordion(label="Advanced Settings", open=False):
|
319 |
with gr.Row():
|
320 |
denoise_steps = gr.Number(label="Denoising Steps", minimum=20, maximum=40, value=30, step=1)
|
|
|
322 |
|
323 |
|
324 |
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, price_display, url_display])
|
325 |
+
image_gallery.select(select_image, [image_gallery, url_display], [garm_img, buy_link])
|
326 |
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')
|
327 |
+
buy_button.click(fn=open_link, input=buy_link, outputs= output)
|
328 |
|
329 |
image_blocks.launch()
|