Spaces:
Build error
Build error
Commit ·
6f3703b
1
Parent(s): d3a35cb
computer vision 1
Browse files
app.py
CHANGED
|
@@ -51,42 +51,47 @@ interface_image = gr.Interface(
|
|
| 51 |
cache_examples=False,
|
| 52 |
)
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
if ret:
|
| 59 |
-
frame_copy = frame.copy()
|
| 60 |
-
outputs = model.predict(source=frame)
|
| 61 |
-
results = outputs[0].cpu().numpy()
|
| 62 |
-
for i, det in enumerate(results.boxes.xyxy):
|
| 63 |
-
cv2.rectangle(
|
| 64 |
-
frame_copy,
|
| 65 |
-
(int(det[0]), int(det[1])),
|
| 66 |
-
(int(det[2]), int(det[3])),
|
| 67 |
-
color=(0, 0, 255),
|
| 68 |
-
thickness=2,
|
| 69 |
-
lineType=cv2.LINE_AA
|
| 70 |
-
)
|
| 71 |
-
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
gr.components.Image(type="numpy", label="Output Image"),
|
| 79 |
-
]
|
| 80 |
-
interface_video = gr.Interface(
|
| 81 |
-
fn=show_preds_video,
|
| 82 |
-
inputs=inputs_video,
|
| 83 |
-
outputs=outputs_video,
|
| 84 |
-
title="Video Processing ",
|
| 85 |
-
examples=video_path,
|
| 86 |
-
cache_examples=False,
|
| 87 |
-
)
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
cache_examples=False,
|
| 52 |
)
|
| 53 |
|
| 54 |
+
gr.TabbedInterface(
|
| 55 |
+
[interface_image],
|
| 56 |
+
tab_names=['Image Processing']
|
| 57 |
+
).queue().launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
# def show_preds_video(video_path):
|
| 60 |
+
# cap = cv2.VideoCapture(video_path)
|
| 61 |
+
# while(cap.isOpened()):
|
| 62 |
+
# ret, frame = cap.read()
|
| 63 |
+
# if ret:
|
| 64 |
+
# frame_copy = frame.copy()
|
| 65 |
+
# outputs = model.predict(source=frame)
|
| 66 |
+
# results = outputs[0].cpu().numpy()
|
| 67 |
+
# for i, det in enumerate(results.boxes.xyxy):
|
| 68 |
+
# cv2.rectangle(
|
| 69 |
+
# frame_copy,
|
| 70 |
+
# (int(det[0]), int(det[1])),
|
| 71 |
+
# (int(det[2]), int(det[3])),
|
| 72 |
+
# color=(0, 0, 255),
|
| 73 |
+
# thickness=2,
|
| 74 |
+
# lineType=cv2.LINE_AA
|
| 75 |
+
# )
|
| 76 |
+
# yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
| 77 |
|
| 78 |
+
# inputs_video = [
|
| 79 |
+
# gr.components.Video(type="filepath", label="Input Video"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
# ]
|
| 82 |
+
# outputs_video = [
|
| 83 |
+
# gr.components.Image(type="numpy", label="Output Image"),
|
| 84 |
+
# ]
|
| 85 |
+
# interface_video = gr.Interface(
|
| 86 |
+
# fn=show_preds_video,
|
| 87 |
+
# inputs=inputs_video,
|
| 88 |
+
# outputs=outputs_video,
|
| 89 |
+
# title="Video Processing ",
|
| 90 |
+
# examples=video_path,
|
| 91 |
+
# cache_examples=False,
|
| 92 |
+
# )
|
| 93 |
+
|
| 94 |
+
# gr.TabbedInterface(
|
| 95 |
+
# [interface_image, interface_video],
|
| 96 |
+
# tab_names=['Image inference', 'Video inference']
|
| 97 |
+
# ).queue().launch()
|