Spaces:
Runtime error
Runtime error
add change
Browse files
app.py
CHANGED
@@ -44,12 +44,14 @@ def pil_to_binary_mask(pil_image, threshold=0):
|
|
44 |
def fetch_products(query):
|
45 |
result= amazon_oxy.scrape_amazon(query)
|
46 |
values = list(result.values())
|
47 |
-
|
48 |
urls = []
|
|
|
49 |
for price, url in values:
|
50 |
-
|
|
|
51 |
urls.append(url)
|
52 |
-
return [
|
53 |
|
54 |
base_path = 'yisol/IDM-VTON'
|
55 |
example_path = os.path.join(os.path.dirname(__file__), 'example')
|
@@ -318,9 +320,14 @@ with image_blocks as demo:
|
|
318 |
seed = gr.Number(label="Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
319 |
|
320 |
|
321 |
-
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery,
|
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=None,inputs=buy_link,js=f"(buy_link) => {{ window.open(buy_link.substring(buy_link.indexOf('amazon.com')), '_blank');console.log(buy_link) }}")
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
326 |
image_blocks.launch()
|
|
|
44 |
def fetch_products(query):
|
45 |
result= amazon_oxy.scrape_amazon(query)
|
46 |
values = list(result.values())
|
47 |
+
pic_and_prices = []
|
48 |
urls = []
|
49 |
+
i = 0
|
50 |
for price, url in values:
|
51 |
+
pic_and_prices.append((values[i], "$"+str(price)))
|
52 |
+
i+=1
|
53 |
urls.append(url)
|
54 |
+
return [pic_and_prices, urls]
|
55 |
|
56 |
base_path = 'yisol/IDM-VTON'
|
57 |
example_path = os.path.join(os.path.dirname(__file__), 'example')
|
|
|
320 |
seed = gr.Number(label="Seed", minimum=-1, maximum=2147483647, step=1, value=42)
|
321 |
|
322 |
|
323 |
+
fetch_button.click(fn=fetch_products, inputs=prompt, outputs=[image_gallery, 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=None,inputs=buy_link,js=f"(buy_link) => {{ window.open(buy_link.substring(buy_link.indexOf('amazon.com')), '_blank');console.log(buy_link) }}")
|
327 |
+
buy_button.click(fn=None,inputs=buy_link, js=f"(buy_link) => {{
|
328 |
+
const clean_link = buy_link.includes('http') ? buy_link : 'https://' + buy_link;
|
329 |
+
window.open(clean_link.substring(clean_link.indexOf('amazon.com')), '_blank');
|
330 |
+
console.log(clean_link);
|
331 |
+
}}")
|
332 |
+
|
333 |
image_blocks.launch()
|