ysr commited on
Commit
5c41f30
1 Parent(s): aba4139

get rid of video inference

Browse files
Files changed (1) hide show
  1. app.py +3 -35
app.py CHANGED
@@ -40,42 +40,10 @@ interface_image = gr.Interface(
40
  )
41
 
42
 
43
- def show_preds_video(video_path):
44
- cap = cv2.VideoCapture(video_path)
45
- while(cap.isOpened()):
46
- ret, frame = cap.read()
47
- if ret:
48
- frame_copy = frame.copy()
49
- outputs = model.predict(source=frame, conf=0.45)
50
- results = outputs[0]
51
- for i, det in enumerate(results.boxes.xyxy.cpu().numpy()):
52
- cv2.rectangle(
53
- frame_copy,
54
- (int(det[0]), int(det[1])),
55
- (int(det[2]), int(det[3])),
56
- color=(random.randint(0,255), random.randint(0,255), random.randint(0,255)),
57
- thickness=2,
58
- lineType=cv2.LINE_AA
59
- )
60
- yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
61
-
62
- inputs_video = [
63
- gr.components.Video(type="filepath", label="Input Video"),
64
-
65
- ]
66
- outputs_video = [
67
- gr.components.Image(type="numpy", label="Output Image"),
68
- ]
69
- interface_video = gr.Interface(
70
- fn=show_preds_video,
71
- inputs=inputs_video,
72
- outputs=outputs_video,
73
- title="Cats and Dogs detector",
74
- cache_examples=False,
75
- )
76
 
77
 
78
  gr.TabbedInterface(
79
- [interface_image, interface_video],
80
- tab_names=['Image inference', 'Video inference']
81
  ).queue().launch()
 
40
  )
41
 
42
 
43
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
 
46
  gr.TabbedInterface(
47
+ [interface_image],
48
+ tab_names=['Image inference']
49
  ).queue().launch()