Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,11 @@ def validate_item(item_id: str, use_title: bool, threshold: float):
|
|
18 |
|
19 |
def validate_images(img_url_1, img_url_2, img_url_3, domain: str, title: str, threshold: float):
|
20 |
img_urls = [url for url in [img_url_1, img_url_2, img_url_3] if url != ""]
|
|
|
|
|
21 |
if title == "":
|
22 |
title = None
|
23 |
-
images, domain, probas, valid_probas, invalid_probas = detector.predict_probas_url(img_urls, domain, title)
|
24 |
valid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() >= threshold]
|
25 |
invalid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() < threshold]
|
26 |
return f"## Domain: {domain}", valid_images, invalid_images
|
@@ -60,7 +62,7 @@ with gr.Blocks() as demo:
|
|
60 |
img_url_2 = gr.Textbox(label="Picture URL")
|
61 |
img_url_3 = gr.Textbox(label="Picture URL")
|
62 |
with gr.Column():
|
63 |
-
domain = gr.Textbox(label="Domain
|
64 |
title = gr.Textbox(label="Item title", placeholder="Optional")
|
65 |
threshold = gr.Number(label="Threshold", value=0.25, precision=2)
|
66 |
submit = gr.Button("Submit")
|
|
|
18 |
|
19 |
def validate_images(img_url_1, img_url_2, img_url_3, domain: str, title: str, threshold: float):
|
20 |
img_urls = [url for url in [img_url_1, img_url_2, img_url_3] if url != ""]
|
21 |
+
site, domain = domain.split("-")
|
22 |
+
domain = domain.replace("_", " ").lower()
|
23 |
if title == "":
|
24 |
title = None
|
25 |
+
images, domain, probas, valid_probas, invalid_probas = detector.predict_probas_url(img_urls, domain, site, title)
|
26 |
valid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() >= threshold]
|
27 |
invalid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() < threshold]
|
28 |
return f"## Domain: {domain}", valid_images, invalid_images
|
|
|
62 |
img_url_2 = gr.Textbox(label="Picture URL")
|
63 |
img_url_3 = gr.Textbox(label="Picture URL")
|
64 |
with gr.Column():
|
65 |
+
domain = gr.Textbox(label="Domain ID", placeholder="Required")
|
66 |
title = gr.Textbox(label="Item title", placeholder="Optional")
|
67 |
threshold = gr.Number(label="Threshold", value=0.25, precision=2)
|
68 |
submit = gr.Button("Submit")
|