-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
21 lines (17 loc) · 699 Bytes
/
Copy pathapp.py
File metadata and controls
21 lines (17 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import streamlit as st
import cv2
import torch
import numpy as np
# Load YOLOv5 model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
st.title("Real-Time Object Detection")
# Upload an image
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:
# Read the image
image = cv2.imdecode(np.frombuffer(uploaded_file.read(), np.uint8), cv2.IMREAD_COLOR)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Run detection
results = model(image)
st.write(results.pandas().xyxy[0]) # Display detection results
st.image(results.render()[0], caption="Detected Image", use_column_width=True)