Clement Vachet commited on
Commit
2ccf6ca
1 Parent(s): 0ee6bfc

Add threshold UI component

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -45,11 +45,11 @@ def get_output_figure(pil_img, results, threshold):
45
 
46
 
47
  #@spaces.GPU
48
- def detect(image):
49
  results = model_pipeline(image)
50
  print(results)
51
 
52
- output_figure = get_output_figure(image, results, threshold=0.9)
53
 
54
  buf = io.BytesIO()
55
  output_figure.savefig(buf, bbox_inches="tight")
@@ -71,9 +71,10 @@ with gr.Blocks() as demo:
71
 
72
  gr.Interface(
73
  fn=detect,
74
- inputs=gr.Image(label="Input image", type="pil"),
 
75
  outputs=[gr.Image(label="Output prediction", type="pil")],
76
- examples=['samples/savanna.jpg'],
77
  )
78
 
79
  demo.launch(show_error=True)
 
45
 
46
 
47
  #@spaces.GPU
48
+ def detect(image, threshold=0.9):
49
  results = model_pipeline(image)
50
  print(results)
51
 
52
+ output_figure = get_output_figure(image, results, threshold=threshold)
53
 
54
  buf = io.BytesIO()
55
  output_figure.savefig(buf, bbox_inches="tight")
 
71
 
72
  gr.Interface(
73
  fn=detect,
74
+ inputs=[gr.Image(label="Input image", type="pil"), \
75
+ gr.Slider(0, 1.0, value=0.9, label='Threshold')],
76
  outputs=[gr.Image(label="Output prediction", type="pil")],
77
+ examples=[['samples/savanna.jpg']],
78
  )
79
 
80
  demo.launch(show_error=True)