pirahansiah commited on
Commit
89e42b0
·
1 Parent(s): 077796f

computer vision 1

Browse files
Files changed (1) hide show
  1. app.py +37 -37
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import cv2
3
  import requests
4
  import os
5
-
6
  from ultralytics import YOLO
7
 
8
  file_urls = [
@@ -50,42 +50,42 @@ interface_image = gr.Interface(
50
  cache_examples=False,
51
  )
52
 
53
- def show_preds_video(video_path):
54
- cap = cv2.VideoCapture(video_path)
55
- while(cap.isOpened()):
56
- ret, frame = cap.read()
57
- if ret:
58
- frame_copy = frame.copy()
59
- outputs = model.predict(source=frame)
60
- results = outputs[0].cpu().numpy()
61
- for i, det in enumerate(results.boxes.xyxy):
62
- cv2.rectangle(
63
- frame_copy,
64
- (int(det[0]), int(det[1])),
65
- (int(det[2]), int(det[3])),
66
- color=(0, 0, 255),
67
- thickness=2,
68
- lineType=cv2.LINE_AA
69
- )
70
- yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
71
 
72
- inputs_video = [
73
- gr.components.Video(type="filepath", label="Input Video"),
74
 
75
- ]
76
- outputs_video = [
77
- gr.components.Image(type="numpy", label="Output Image"),
78
- ]
79
- interface_video = gr.Interface(
80
- fn=show_preds_video,
81
- inputs=inputs_video,
82
- outputs=outputs_video,
83
- title="Pothole detector",
84
- examples=video_path,
85
- cache_examples=False,
86
- )
87
 
88
- gr.TabbedInterface(
89
- [interface_image, interface_video],
90
- tab_names=['Image inference', 'Video inference']
91
- ).queue().launch()
 
2
  import cv2
3
  import requests
4
  import os
5
+ #pirahansiah/ComputerVision
6
  from ultralytics import YOLO
7
 
8
  file_urls = [
 
50
  cache_examples=False,
51
  )
52
 
53
+ # def show_preds_video(video_path):
54
+ # cap = cv2.VideoCapture(video_path)
55
+ # while(cap.isOpened()):
56
+ # ret, frame = cap.read()
57
+ # if ret:
58
+ # frame_copy = frame.copy()
59
+ # outputs = model.predict(source=frame)
60
+ # results = outputs[0].cpu().numpy()
61
+ # for i, det in enumerate(results.boxes.xyxy):
62
+ # cv2.rectangle(
63
+ # frame_copy,
64
+ # (int(det[0]), int(det[1])),
65
+ # (int(det[2]), int(det[3])),
66
+ # color=(0, 0, 255),
67
+ # thickness=2,
68
+ # lineType=cv2.LINE_AA
69
+ # )
70
+ # yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
71
 
72
+ # inputs_video = [
73
+ # gr.components.Video(type="filepath", label="Input Video"),
74
 
75
+ # ]
76
+ # outputs_video = [
77
+ # gr.components.Image(type="numpy", label="Output Image"),
78
+ # ]
79
+ # interface_video = gr.Interface(
80
+ # fn=show_preds_video,
81
+ # inputs=inputs_video,
82
+ # outputs=outputs_video,
83
+ # title="Pothole detector",
84
+ # examples=video_path,
85
+ # cache_examples=False,
86
+ # )
87
 
88
+ # gr.TabbedInterface(
89
+ # [interface_image, interface_video],
90
+ # tab_names=['Image inference', 'Video inference']
91
+ # ).queue().launch()