2lu commited on
Commit
3727901
·
1 Parent(s): 32519f3

yolov8 accident detector

Browse files
Files changed (1) hide show
  1. app.py +1 -33
app.py CHANGED
@@ -25,50 +25,18 @@ def yolov8_func(image):
25
 
26
  render = render_result(model=model, image=image, result=results[0])
27
 
28
- return render, box.cls
29
-
30
- # inputs = [
31
- # gr.inputs.Image(type="filepath", label="Input Image"),
32
- # gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
33
- # gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
34
- # gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="Iou Threshold")
35
- # ]
36
-
37
- # gr.HTML
38
- # outputs = gr.outputs.Image(type="filepath", label="Output Image")
39
-
40
- # yolo_app = gr.Interface(
41
- # fn=yolov8_func,
42
- # inputs=inputs,
43
- # outputs=outputs,
44
- # title="Accident detector",
45
- # )
46
-
47
- # yolo_app.launch(debug=True, enable_queue=True)
48
 
49
  with gr.Blocks(title="YOLOS Object Detection - ClassCat", css=".gradio-container {background:lightyellow;}") as demo:
50
  gr.HTML('<h1>Yolo Object Detection</h1>')
51
- #gr.HTML("<h4>supported objects are [aeroplane,bicycle,bird,boat,bottle,bus,car,cat,chair,cow,diningtable,dog,horse,motorbike,person,pottedplant,sheep,sofa,train,tvmonitor]</h4>")
52
  gr.HTML("<br>")
53
  with gr.Row():
54
  input_image = gr.Image(label="Input image", type="pil")
55
  output_image = gr.Image(label="Output image", type="pil")
56
  output_label = gr.Text(label="output label")
57
  gr.HTML("<br>")
58
- #gr.HTML("<h4>object centre detection threshold means the object centre will be considered a new object if it's value is above threshold</h4>")
59
- #gr.HTML("<p>less means more objects</p>")
60
- #gr.HTML("<h4>bounding box threshold is IOU value threshold. If intersection/union area of two bounding boxes are greater than threshold value the one box will be suppressed</h4>")
61
- #gr.HTML("<p>more means more bounding boxes<p>")
62
- #gr.HTML("<br>")
63
-
64
- #obj_threshold = gr.Slider(0, 1.0, value=0.2, label=' object centre detection threshold')
65
- #gr.HTML("<br>")
66
- #bb_threshold = gr.Slider(0, 1.0, value=0.3, label=' bounding box draw threshold')
67
- #gr.HTML("<br>")
68
-
69
  send_btn = gr.Button("Detect")
70
  gr.HTML("<br>")
71
- #gr.Examples(['./samples/out_1.jpg'], inputs=input_image)
72
 
73
  send_btn.click(fn=yolov8_func, inputs=[input_image], outputs=[output_image, output_label])
74
 
 
25
 
26
  render = render_result(model=model, image=image, result=results[0])
27
 
28
+ return (render, box.cls)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  with gr.Blocks(title="YOLOS Object Detection - ClassCat", css=".gradio-container {background:lightyellow;}") as demo:
31
  gr.HTML('<h1>Yolo Object Detection</h1>')
 
32
  gr.HTML("<br>")
33
  with gr.Row():
34
  input_image = gr.Image(label="Input image", type="pil")
35
  output_image = gr.Image(label="Output image", type="pil")
36
  output_label = gr.Text(label="output label")
37
  gr.HTML("<br>")
 
 
 
 
 
 
 
 
 
 
 
38
  send_btn = gr.Button("Detect")
39
  gr.HTML("<br>")
 
40
 
41
  send_btn.click(fn=yolov8_func, inputs=[input_image], outputs=[output_image, output_label])
42