Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,15 @@ def validate(item_id: str, threshold: float):
|
|
8 |
images, domain, probas, valid_probas, invalid_probas = detector.predict_probas_item(item_id)
|
9 |
valid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() >= threshold]
|
10 |
invalid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() < threshold]
|
11 |
-
return f"
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
gr.Markdown("""
|
15 |
# Off topic image detector
|
16 |
-
|
17 |
Input an item ID or select one of the preloaded examples below.""")
|
18 |
item_id = gr.Textbox(label="Item ID")
|
19 |
-
threshold = gr.Number(label="Threshold", value=0.
|
20 |
submit = gr.Button("Submit")
|
21 |
gr.HTML("<hr>")
|
22 |
domain = gr.Markdown()
|
@@ -26,7 +26,7 @@ with gr.Blocks() as demo:
|
|
26 |
submit.click(inputs=[item_id, threshold], outputs=[domain, valid, invalid], fn=validate)
|
27 |
gr.HTML("<hr>")
|
28 |
gr.Examples(
|
29 |
-
examples=[["MLU449951849", 0.
|
30 |
inputs=[item_id, threshold],
|
31 |
outputs=[domain, valid, invalid],
|
32 |
fn=validate,
|
|
|
8 |
images, domain, probas, valid_probas, invalid_probas = detector.predict_probas_item(item_id)
|
9 |
valid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() >= threshold]
|
10 |
invalid_images = [x for i, x in enumerate(images) if valid_probas[i].squeeze() < threshold]
|
11 |
+
return f"## Domain: {domain}", valid_images, invalid_images
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
gr.Markdown("""
|
15 |
# Off topic image detector
|
16 |
+
### This app takes an item ID and classifies its pictures as valid/invalid depending on whether they relate to the domain in which it's been listed.
|
17 |
Input an item ID or select one of the preloaded examples below.""")
|
18 |
item_id = gr.Textbox(label="Item ID")
|
19 |
+
threshold = gr.Number(label="Threshold", value=0.25)
|
20 |
submit = gr.Button("Submit")
|
21 |
gr.HTML("<hr>")
|
22 |
domain = gr.Markdown()
|
|
|
26 |
submit.click(inputs=[item_id, threshold], outputs=[domain, valid, invalid], fn=validate)
|
27 |
gr.HTML("<hr>")
|
28 |
gr.Examples(
|
29 |
+
examples=[["MLU449951849", 0.25], ["MLA1293465558", 0.25], ["MLB3184663685", 0.25], ["MLC1392230619", 0.25]],
|
30 |
inputs=[item_id, threshold],
|
31 |
outputs=[domain, valid, invalid],
|
32 |
fn=validate,
|