Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
-
from huggingface_hub import hf_hub_download
|
| 2 |
-
from inference import YOLOv10
|
| 3 |
import gradio as gr
|
| 4 |
import cv2
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
from gradio_webrtc import WebRTC
|
| 7 |
from twilio.rest import Client
|
| 8 |
import os
|
|
|
|
| 9 |
|
| 10 |
model_file = hf_hub_download(
|
| 11 |
repo_id="onnx-community/yolov10n", filename="onnx/model.onnx"
|
|
@@ -13,11 +12,6 @@ model_file = hf_hub_download(
|
|
| 13 |
|
| 14 |
model = YOLOv10(model_file)
|
| 15 |
|
| 16 |
-
def detection(image, conf_threshold=0.3):
|
| 17 |
-
image = cv2.resize(image, (model.input_width, model.input_height))
|
| 18 |
-
new_image = model.detect_objects(image, conf_threshold)
|
| 19 |
-
return new_image
|
| 20 |
-
|
| 21 |
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
| 22 |
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
| 23 |
|
|
@@ -33,15 +27,30 @@ if account_sid and auth_token:
|
|
| 33 |
else:
|
| 34 |
rtc_configuration = None
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
with gr.Blocks(css=css) as demo:
|
| 40 |
gr.HTML(
|
| 41 |
"""
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
"""
|
| 46 |
)
|
| 47 |
with gr.Column(elem_classes=["my-column"]):
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
from gradio_webrtc import WebRTC
|
| 5 |
from twilio.rest import Client
|
| 6 |
import os
|
| 7 |
+
from inference import YOLOv10
|
| 8 |
|
| 9 |
model_file = hf_hub_download(
|
| 10 |
repo_id="onnx-community/yolov10n", filename="onnx/model.onnx"
|
|
|
|
| 12 |
|
| 13 |
model = YOLOv10(model_file)
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
| 16 |
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
| 17 |
|
|
|
|
| 27 |
else:
|
| 28 |
rtc_configuration = None
|
| 29 |
|
| 30 |
+
|
| 31 |
+
def detection(image, conf_threshold=0.3):
|
| 32 |
+
image = cv2.resize(image, (model.input_width, model.input_height))
|
| 33 |
+
new_image = model.detect_objects(image, conf_threshold)
|
| 34 |
+
return cv2.resize(new_image, (500, 500))
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
css = """.my-group {max-width: 600px !important; max-height: 600 !important;}
|
| 38 |
+
.my-column {display: flex !important; justify-content: center !important; align-items: center !important};"""
|
| 39 |
+
|
| 40 |
|
| 41 |
with gr.Blocks(css=css) as demo:
|
| 42 |
gr.HTML(
|
| 43 |
"""
|
| 44 |
+
<h1 style='text-align: center'>
|
| 45 |
+
YOLOv10 Webcam Stream (Powered by WebRTC ⚡️)
|
| 46 |
+
</h1>
|
| 47 |
+
"""
|
| 48 |
+
)
|
| 49 |
+
gr.HTML(
|
| 50 |
+
"""
|
| 51 |
+
<h3 style='text-align: center'>
|
| 52 |
+
<a href='https://arxiv.org/abs/2405.14458' target='_blank'>arXiv</a> | <a href='https://github.com/THU-MIG/yolov10' target='_blank'>github</a>
|
| 53 |
+
</h3>
|
| 54 |
"""
|
| 55 |
)
|
| 56 |
with gr.Column(elem_classes=["my-column"]):
|