akshaikrishna
commited on
Commit
•
53749f4
1
Parent(s):
b66c587
Add app and requirements files
Browse files- .gitignore +2 -0
- app.py +41 -0
- requirements.txt +86 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
yolo11n.pt
|
2 |
+
.gradio
|
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ultralytics import YOLO
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_webrtc import WebRTC
|
4 |
+
|
5 |
+
# Load the YOLO model
|
6 |
+
model = YOLO("yolo11n.pt")
|
7 |
+
|
8 |
+
|
9 |
+
def detect_objects(frame, conf_threshold=0.3):
|
10 |
+
results = model(frame, conf=conf_threshold)
|
11 |
+
annotated_frame = results[0].plot()
|
12 |
+
return annotated_frame
|
13 |
+
|
14 |
+
|
15 |
+
css = """.my-group {max-width: 600px !important; max-height: 600px !important;}
|
16 |
+
.my-column {display: flex !important; justify-content: center !important; align-items: center !important;}"""
|
17 |
+
|
18 |
+
with gr.Blocks(css=css) as demo:
|
19 |
+
gr.HTML(
|
20 |
+
"<h1 style='text-align: center'>YOLOv10 Webcam Stream (Powered by WebRTC ⚡️)</h1>"
|
21 |
+
)
|
22 |
+
|
23 |
+
with gr.Column(elem_classes=["my-column"]):
|
24 |
+
image = WebRTC(label="Stream")
|
25 |
+
conf_threshold = gr.Slider(
|
26 |
+
label="Confidence Threshold",
|
27 |
+
minimum=0.0,
|
28 |
+
maximum=1.0,
|
29 |
+
step=0.05,
|
30 |
+
value=0.30,
|
31 |
+
)
|
32 |
+
|
33 |
+
# Stream processing function
|
34 |
+
image.stream(
|
35 |
+
fn=detect_objects,
|
36 |
+
inputs=[image, conf_threshold],
|
37 |
+
outputs=[image],
|
38 |
+
time_limit=10,
|
39 |
+
)
|
40 |
+
|
41 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.2.1
|
2 |
+
aioice==0.9.0
|
3 |
+
aiortc==1.9.0
|
4 |
+
annotated-types==0.7.0
|
5 |
+
anyio==4.6.2.post1
|
6 |
+
av==12.3.0
|
7 |
+
certifi==2024.8.30
|
8 |
+
cffi==1.17.1
|
9 |
+
charset-normalizer==3.4.0
|
10 |
+
click==8.1.7
|
11 |
+
contourpy==1.3.0
|
12 |
+
cryptography==43.0.3
|
13 |
+
cycler==0.12.1
|
14 |
+
deep-sort-realtime==1.3.2
|
15 |
+
dnspython==2.7.0
|
16 |
+
fastapi==0.115.3
|
17 |
+
ffmpy==0.4.0
|
18 |
+
filelock==3.16.1
|
19 |
+
fonttools==4.54.1
|
20 |
+
fsspec==2024.10.0
|
21 |
+
google-crc32c==1.6.0
|
22 |
+
gradio==5.4.0
|
23 |
+
gradio_client==1.4.2
|
24 |
+
gradio_webrtc==0.0.11
|
25 |
+
h11==0.14.0
|
26 |
+
httpcore==1.0.6
|
27 |
+
httpx==0.27.2
|
28 |
+
huggingface-hub==0.26.1
|
29 |
+
idna==3.10
|
30 |
+
ifaddr==0.2.0
|
31 |
+
Jinja2==3.1.4
|
32 |
+
kiwisolver==1.4.7
|
33 |
+
markdown-it-py==3.0.0
|
34 |
+
MarkupSafe==2.1.5
|
35 |
+
matplotlib==3.9.2
|
36 |
+
mdurl==0.1.2
|
37 |
+
mpmath==1.3.0
|
38 |
+
networkx==3.4.2
|
39 |
+
numpy==1.26.4
|
40 |
+
opencv-contrib-python==4.10.0.84
|
41 |
+
opencv-python==4.10.0.84
|
42 |
+
opencv-python-headless==4.10.0.84
|
43 |
+
orjson==3.10.10
|
44 |
+
packaging==24.1
|
45 |
+
pandas==2.2.3
|
46 |
+
pillow==11.0.0
|
47 |
+
psutil==6.1.0
|
48 |
+
py-cpuinfo==9.0.0
|
49 |
+
pycparser==2.22
|
50 |
+
pydantic==2.9.2
|
51 |
+
pydantic_core==2.23.4
|
52 |
+
pydub==0.25.1
|
53 |
+
pyee==12.0.0
|
54 |
+
Pygments==2.18.0
|
55 |
+
pylibsrtp==0.10.0
|
56 |
+
pyOpenSSL==24.2.1
|
57 |
+
pyparsing==3.2.0
|
58 |
+
python-dateutil==2.9.0.post0
|
59 |
+
python-multipart==0.0.12
|
60 |
+
pytz==2024.2
|
61 |
+
PyYAML==6.0.2
|
62 |
+
requests==2.32.3
|
63 |
+
rich==13.9.3
|
64 |
+
ruff==0.7.1
|
65 |
+
safehttpx==0.1.1
|
66 |
+
scipy==1.14.1
|
67 |
+
seaborn==0.13.2
|
68 |
+
semantic-version==2.10.0
|
69 |
+
setuptools==75.3.0
|
70 |
+
shellingham==1.5.4
|
71 |
+
six==1.16.0
|
72 |
+
sniffio==1.3.1
|
73 |
+
starlette==0.41.2
|
74 |
+
sympy==1.13.1
|
75 |
+
tomlkit==0.12.0
|
76 |
+
torch==2.5.1
|
77 |
+
torchvision==0.20.1
|
78 |
+
tqdm==4.66.5
|
79 |
+
typer==0.12.5
|
80 |
+
typing_extensions==4.12.2
|
81 |
+
tzdata==2024.2
|
82 |
+
ultralytics==8.3.27
|
83 |
+
ultralytics-thop==2.0.10
|
84 |
+
urllib3==2.2.3
|
85 |
+
uvicorn==0.32.0
|
86 |
+
websockets==12.0
|