kisa-misa commited on
Commit
69c1f1a
·
1 Parent(s): 136b488

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -44,12 +44,15 @@ def fn_video(video_file, conf_thres, iou_thres, start_sec, duration):
44
  except Exception as e:
45
  print(e)
46
  continue
47
- print("FRAME DTYPE", type(frame))
48
- out.write(pipeline(frame, conf_thres, iou_thres))
49
- num_frames += 1
50
- print("Processed {} frames".format(num_frames))
51
- if num_frames == max_frames:
52
- break
 
 
 
53
 
54
  out.release()
55
 
@@ -60,6 +63,11 @@ def fn_video(video_file, conf_thres, iou_thres, start_sec, duration):
60
  return out_file.name
61
 
62
 
 
 
 
 
 
63
  image_interface = gr.Interface(
64
  fn=fn_image,
65
  inputs=[
@@ -68,7 +76,7 @@ image_interface = gr.Interface(
68
  gr.Slider(0, 1, value=0.5, label="IOU Threshold"),
69
  ],
70
  outputs=gr.Image(type="file"),
71
- examples=[["example_1.jpg", 0.5, 0.5], ["example_2.jpg", 0.25, 0.45], ["example_3.jpg", 0.25, 0.45]],
72
  title="YOLOv6",
73
  description=(
74
  "Gradio demo for YOLOv6 for object detection on images. To use it, simply upload your image or click one of the"
@@ -90,7 +98,7 @@ video_interface = gr.Interface(
90
  gr.Slider(0, 1, value=0.25, label="Confidence Threshold"),
91
  gr.Slider(0, 1, value=0.45, label="IOU Threshold"),
92
  gr.Slider(0, 10, value=0, label="Start Second", step=1),
93
- gr.Slider(0, 10 if pipeline.device.type != 'cpu' else 3, value=4, label="Duration", step=1),
94
  ],
95
  outputs=gr.Video(type="file", format="mp4"),
96
  examples=[
 
44
  except Exception as e:
45
  print(e)
46
  continue
47
+ if (num_frames%10 != 0):
48
+ continue
49
+ else:
50
+ print("FRAME DTYPE", type(frame))
51
+ out.write(pipeline(frame, conf_thres, iou_thres))
52
+ num_frames += 1
53
+ print("Processed {} frames".format(num_frames))
54
+ if num_frames == max_frames:
55
+ break
56
 
57
  out.release()
58
 
 
63
  return out_file.name
64
 
65
 
66
+ torch.hub.download_url_to_file('https://tochkanews.ru/wp-content/uploads/2020/09/0.jpg', '1.jpg')
67
+ torch.hub.download_url_to_file('https://s.rdrom.ru/1/pubs/4/35893/1906770.jpg', '2.jpg')
68
+ torch.hub.download_url_to_file('https://static.mk.ru/upload/entities/2022/04/17/07/articles/detailPicture/5b/39/28/b6/ffb1aa636dd62c30e6ff670f84474f75.jpg', '3.jpg')
69
+
70
+
71
  image_interface = gr.Interface(
72
  fn=fn_image,
73
  inputs=[
 
76
  gr.Slider(0, 1, value=0.5, label="IOU Threshold"),
77
  ],
78
  outputs=gr.Image(type="file"),
79
+ examples=[["1.jpg", 0.5, 0.5], ["2.jpg", 0.25, 0.45], ["3.jpg", 0.25, 0.45]],
80
  title="YOLOv6",
81
  description=(
82
  "Gradio demo for YOLOv6 for object detection on images. To use it, simply upload your image or click one of the"
 
98
  gr.Slider(0, 1, value=0.25, label="Confidence Threshold"),
99
  gr.Slider(0, 1, value=0.45, label="IOU Threshold"),
100
  gr.Slider(0, 10, value=0, label="Start Second", step=1),
101
+ gr.Slider(0, 10 if pipeline.device.type != 'cpu' else 3, value=3, label="Duration", step=1),
102
  ],
103
  outputs=gr.Video(type="file", format="mp4"),
104
  examples=[