Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
from huggingface_hub import hf_hub_download
|
| 2 |
-
from inference import YOLOv10
|
| 3 |
-
|
| 4 |
-
model_file = hf_hub_download(
|
| 5 |
-
repo_id="onnx-community/yolov10n", filename="onnx/model.onnx"
|
| 6 |
-
)
|
| 7 |
-
|
| 8 |
-
model = YOLOv10(model_file)
|
| 9 |
-
|
| 10 |
-
def detection(image, conf_threshold=0.3):
|
| 11 |
-
image = cv2.resize(image, (model.input_width, model.input_height))
|
| 12 |
-
new_image = model.detect_objects(image, conf_threshold)
|
| 13 |
-
return new_image
|
| 14 |
-
|
| 15 |
-
import gradio as gr
|
| 16 |
-
from gradio_webrtc import WebRTC
|
| 17 |
-
|
| 18 |
-
css = """.my-group {max-width: 600px !important; max-height: 600px !important;}
|
| 19 |
-
.my-column {display: flex !important; justify-content: center !important; align-items: center !important;}"""
|
| 20 |
-
|
| 21 |
-
with gr.Blocks(css=css) as demo:
|
| 22 |
-
gr.HTML(
|
| 23 |
-
"""
|
| 24 |
-
<h1 style='text-align: center'>
|
| 25 |
-
YOLOv10 Webcam Stream (Powered by WebRTC ⚡️)
|
| 26 |
-
</h1>
|
| 27 |
-
"""
|
| 28 |
-
)
|
| 29 |
-
with gr.Column(elem_classes=["my-column"]):
|
| 30 |
-
with gr.Group(elem_classes=["my-group"]):
|
| 31 |
-
image = WebRTC(label="Stream", rtc_configuration=rtc_configuration)
|
| 32 |
-
conf_threshold = gr.Slider(
|
| 33 |
-
label="Confidence Threshold",
|
| 34 |
-
minimum=0.0,
|
| 35 |
-
maximum=1.0,
|
| 36 |
-
step=0.05,
|
| 37 |
-
value=0.30,
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
image.stream(
|
| 41 |
-
fn=detection, inputs=[image, conf_threshold], outputs=[image], time_limit=10
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
if __name__ == "__main__":
|
| 45 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|