Spaces:
Runtime error
Runtime error
Commit ·
a861e69
1
Parent(s): d2b9da2
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,32 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def show_preds_gradio(input_image, display_label, display_bbox, detection_threshold):
|
|
|
|
| 4 |
|
| 5 |
+
if detection_threshold==0: detection_threshold=0.5
|
| 6 |
+
|
| 7 |
+
img = PIL.Image.fromarray(input_image, 'RGB')
|
| 8 |
+
|
| 9 |
+
pred_dict = model_type.end2end_detect(img,
|
| 10 |
+
valid_tfms,
|
| 11 |
+
model_loaded, ##
|
| 12 |
+
class_map=class_map,
|
| 13 |
+
detection_threshold=detection_threshold,
|
| 14 |
+
display_label=display_label,
|
| 15 |
+
display_bbox=display_bbox,
|
| 16 |
+
return_img=True,
|
| 17 |
+
font_size=16,
|
| 18 |
+
label_color="#FF59D6")
|
| 19 |
+
|
| 20 |
+
return pred_dict['img']
|
| 21 |
+
|
| 22 |
+
display_chkbox_label = gr.inputs.Checkbox(label="Label", default=True)
|
| 23 |
+
display_chkbox_box = gr.inputs.Checkbox(label="Box", default=True)
|
| 24 |
+
|
| 25 |
+
detection_threshold_slider = gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0.5, label="Detection Threshold")
|
| 26 |
+
|
| 27 |
+
outputs = gr.outputs.Image(type="pil")
|
| 28 |
+
|
| 29 |
+
# Option 1: Get an image from local drive
|
| 30 |
+
gr_interface = gr.Interface(fn=show_preds_gradio, inputs=["image", display_chkbox_label, display_chkbox_box, detection_threshold_slider], outputs=outputs, title='IceApp - COCO')
|
| 31 |
+
|
| 32 |
+
gr_interface.launch(inline=False, share=True, debug=True)
|