Spaces:
Runtime error
Runtime error
Commit
·
e920a86
1
Parent(s):
2910a31
Update app.py
Browse files
app.py
CHANGED
@@ -75,23 +75,12 @@ interface_image = gr.Interface(
|
|
75 |
|
76 |
##################################################Video Inference################################################################
|
77 |
def show_preds_video(
|
78 |
-
video_path:
|
79 |
-
model_path:
|
80 |
-
image_size:
|
81 |
-
conf_threshold:
|
82 |
-
iou_threshold:
|
83 |
):
|
84 |
-
"""
|
85 |
-
Video inference function
|
86 |
-
Args:
|
87 |
-
video_path: Input video
|
88 |
-
model_path: Path to the model
|
89 |
-
image_size: Image size
|
90 |
-
conf_threshold: Confidence threshold
|
91 |
-
iou_threshold: IOU threshold
|
92 |
-
Returns:
|
93 |
-
Rendered video
|
94 |
-
"""
|
95 |
cap = cv2.VideoCapture(video_path)
|
96 |
|
97 |
while cap.isOpened():
|
@@ -106,8 +95,10 @@ def show_preds_video(
|
|
106 |
results = model.predict(frame)
|
107 |
annotated_frame = results[0].plot()
|
108 |
|
109 |
-
cv2.imshow
|
|
|
110 |
|
|
|
111 |
if cv2.waitKey(1) & 0xFF == ord("q"):
|
112 |
break
|
113 |
else:
|
@@ -115,7 +106,8 @@ def show_preds_video(
|
|
115 |
|
116 |
cap.release()
|
117 |
cv2.destroyAllWindows()
|
118 |
-
|
|
|
119 |
inputs_video = [
|
120 |
gr.components.Video(type="filepath", label="Input Video"),
|
121 |
gr.inputs.Dropdown(["foduucom/stockmarket-pattern-detection-yolov8"],
|
|
|
75 |
|
76 |
##################################################Video Inference################################################################
|
77 |
def show_preds_video(
|
78 |
+
video_path: str = None,
|
79 |
+
model_path: str = None,
|
80 |
+
image_size: int = 640,
|
81 |
+
conf_threshold: float = 0.25,
|
82 |
+
iou_threshold: float = 0.45,
|
83 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
cap = cv2.VideoCapture(video_path)
|
85 |
|
86 |
while cap.isOpened():
|
|
|
95 |
results = model.predict(frame)
|
96 |
annotated_frame = results[0].plot()
|
97 |
|
98 |
+
# Do not display the frame using cv2.imshow
|
99 |
+
# cv2.imshow("YOLOv8 Inference", annotated_frame)
|
100 |
|
101 |
+
# Break the loop if 'q' is pressed
|
102 |
if cv2.waitKey(1) & 0xFF == ord("q"):
|
103 |
break
|
104 |
else:
|
|
|
106 |
|
107 |
cap.release()
|
108 |
cv2.destroyAllWindows()
|
109 |
+
|
110 |
+
|
111 |
inputs_video = [
|
112 |
gr.components.Video(type="filepath", label="Input Video"),
|
113 |
gr.inputs.Dropdown(["foduucom/stockmarket-pattern-detection-yolov8"],
|