Spaces:
Sleeping
Sleeping
Download app.py from BrainAI-1/streamlit_webcam_test: direct link, hf CLI and curl.
- Browser
- Download file 568 Bytes
-
https://huggingface.co/spaces/BrainAI-1/streamlit_webcam_test/resolve/main/app.py
- Command line
-
hf download hf://spaces/BrainAI-1/streamlit_webcam_test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/BrainAI-1/streamlit_webcam_test/resolve/main/app.py
568 Bytes
| import streamlit as st | |
| import cv2 | |
| import numpy as np | |
| import PIL | |
| from ultralytics import YOLO | |
| from camera_input_live import camera_input_live | |
| # Load YOLO model (Download "yolov8n.pt" first if not available) | |
| model = YOLO("yolov8n.pt") | |
| st.title("🎥 YOLO Object Detection Live Stream") | |
| image = camera_input_live() | |
| if image: | |
| uploaded_image = PIL.Image.open(image) | |
| #uploaded_image_cv = cv2.cvtColor(np.array(uploaded_image), cv2.COLOR_RGB2BGR) | |
| result = model(uploaded_image) | |
| img_plot = result[0].plot() | |
| st.image(img_plot, channels = "BGR") |