rxavier commited on
Commit
fd9138f
1 Parent(s): 9c77dee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -8,8 +8,7 @@ def validate(item_id: str, threshold: float):
8
  images, domain, probas, valid_probas, invalid_probas = detector.predict_item_probas(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 valid_images, invalid_images
12
-
13
 
14
  with gr.Blocks() as demo:
15
  with gr.Tabs():
@@ -17,11 +16,9 @@ with gr.Blocks() as demo:
17
  item_id = gr.Textbox(label="Item ID")
18
  threshold = gr.Number(label="Threshold", value=0.5)
19
  submit = gr.Button("Submit")
 
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=[valid, invalid], fn=validate)
23
-
24
 
25
  demo.launch()
26
-
27
-
 
8
  images, domain, probas, valid_probas, invalid_probas = detector.predict_item_probas(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"<h2>Domain: {domain}</h2>", valid_images, invalid_images
 
12
 
13
  with gr.Blocks() as demo:
14
  with gr.Tabs():
 
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()