Spaces:
Sleeping
Sleeping
Update app1.py
Browse files
app1.py
CHANGED
@@ -2,8 +2,8 @@ import cv2
|
|
2 |
import numpy as np
|
3 |
|
4 |
# Load the SSD model and configuration
|
5 |
-
model_path = '
|
6 |
-
config_path = '
|
7 |
|
8 |
# Load the class labels from the COCO dataset
|
9 |
CLASSES = [
|
@@ -56,28 +56,35 @@ def detect_objects_in_frame(frame):
|
|
56 |
|
57 |
return frame
|
58 |
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
print("Error: Could not open video stream.")
|
65 |
-
exit()
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
# Display the resulting frame
|
79 |
-
cv2.imshow("Detected Objects in Video", output_frame)
|
80 |
-
|
81 |
-
# Break the loop if the user presses the 'Esc' key
|
82 |
-
if cv2.waitKey(1) & 0xFF == 27: # 27 is the keycode for 'Esc'
|
83 |
-
break
|
|
|
2 |
import numpy as np
|
3 |
|
4 |
# Load the SSD model and configuration
|
5 |
+
model_path = 'saved_model.pb' # Path to the pre-trained SSD model
|
6 |
+
config_path = 'pipeline.config' # Path to the deploy prototxt file
|
7 |
|
8 |
# Load the class labels from the COCO dataset
|
9 |
CLASSES = [
|
|
|
56 |
|
57 |
return frame
|
58 |
|
59 |
+
import gradio as gr
|
60 |
+
from gradio_webrtc import WebRTC
|
61 |
|
62 |
+
css = """.my-group {max-width: 600px !important; max-height: 600px !important;}
|
63 |
+
.my-column {display: flex !important; justify-content: center !important; align-items: center !important;}"""
|
|
|
|
|
64 |
|
65 |
+
with gr.Blocks(css=css) as demo:
|
66 |
+
gr.HTML(
|
67 |
+
"""
|
68 |
+
<h1 style='text-align: center'>
|
69 |
+
YOLOv10 Webcam Stream (Powered by WebRTC ⚡️)
|
70 |
+
</h1>
|
71 |
+
"""
|
72 |
+
)
|
73 |
+
with gr.Column(elem_classes=["my-column"]):
|
74 |
+
with gr.Group(elem_classes=["my-group"]):
|
75 |
+
image = WebRTC(label="Stream", rtc_configuration=None)
|
76 |
+
conf_threshold = gr.Slider(
|
77 |
+
label="Confidence Threshold",
|
78 |
+
minimum=0.0,
|
79 |
+
maximum=1.0,
|
80 |
+
step=0.05,
|
81 |
+
value=0.30,
|
82 |
+
)
|
83 |
+
|
84 |
+
image.stream(
|
85 |
+
fn=detect_objects_in_frame, inputs=[image, conf_threshold], outputs=[image], time_limit=10
|
86 |
+
)
|
87 |
+
|
88 |
+
if __name__ == "__main__":
|
89 |
+
demo.launch()
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|