Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,14 +11,23 @@ def validate(item_id: str, threshold: float):
|
|
11 |
return f"<h2>Domain: {domain}</h2>", valid_images, invalid_images
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
demo.launch()
|
|
|
11 |
return f"<h2>Domain: {domain}</h2>", 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 where it belongs to.
|
17 |
+
""")
|
18 |
+
item_id = gr.Textbox(label="Item ID")
|
19 |
+
threshold = gr.Number(label="Threshold", value=0.5)
|
20 |
+
submit = gr.Button("Submit")
|
21 |
+
domain = gr.Markdown()
|
22 |
+
valid = gr.Gallery(label="Valid images").style(grid=[1, 2, 3], height="auto")
|
23 |
+
invalid = gr.Gallery(label="Invalid images").style(grid=[1, 2, 3], height="auto")
|
24 |
+
submit.click(inputs=[item_id, threshold], outputs=[domain, valid, invalid], fn=validate)
|
25 |
+
gr.Examples(
|
26 |
+
examples=[["MLU449951849", 0.5], ["MLA1293465558", 0.5]],
|
27 |
+
inputs=[item_id, threshold],
|
28 |
+
outputs=[domain, valid, invalid],
|
29 |
+
fn=validate,
|
30 |
+
cache_examples=True,
|
31 |
+
)
|
32 |
|
33 |
demo.launch()
|