rxavier commited on
Commit
b07e0da
1 Parent(s): e332954

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
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
- with gr.Tabs():
15
- with gr.Tab("From Item ID"):
16
- item_id = gr.Textbox(label="Item ID")
17
- threshold = gr.Number(label="Threshold", value=0.5)
18
- submit = gr.Button("Submit")
19
- domain = gr.HTML()
20
- valid = gr.Gallery(label="Valid images").style(grid=[1, 2, 3], height="auto")
21
- invalid = gr.Gallery(label="Invalid images").style(grid=[1, 2, 3], height="auto")
22
- submit.click(inputs=[item_id, threshold], outputs=[domain, valid, invalid], fn=validate)
 
 
 
 
 
 
 
 
 
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()