Son Ngo
commited on
Commit
·
e6a017b
1
Parent(s):
62dd710
add ui
Browse files- app.py +33 -0
- unet/checkpoint_epoch5.pth +3 -0
- yolo/best.pt +3 -0
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch
|
| 6 |
+
from yolov5 import YOLOv5
|
| 7 |
+
|
| 8 |
+
# Load YOLOv5 model (you can load YOLOv8 similarly)
|
| 9 |
+
model = YOLOv5('yolo/best.pt')
|
| 10 |
+
|
| 11 |
+
st.title("YOLO Object Detection Web App")
|
| 12 |
+
|
| 13 |
+
# Upload image
|
| 14 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 15 |
+
|
| 16 |
+
if uploaded_file is not None:
|
| 17 |
+
# Convert the file to an OpenCV image
|
| 18 |
+
image = Image.open(uploaded_file)
|
| 19 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 20 |
+
st.write("Processing...")
|
| 21 |
+
|
| 22 |
+
# Convert the image to a format compatible with YOLO
|
| 23 |
+
image_np = np.array(image)
|
| 24 |
+
image_cv = cv2.cvtColor(image_np, cv2.COLOR_RGB2BGR)
|
| 25 |
+
|
| 26 |
+
# Perform YOLO detection
|
| 27 |
+
results = model(image_cv)
|
| 28 |
+
|
| 29 |
+
# Render the results
|
| 30 |
+
detected_image = np.squeeze(results.render())
|
| 31 |
+
|
| 32 |
+
# Display result
|
| 33 |
+
st.image(detected_image, caption="Detected Image", use_column_width=True)
|
unet/checkpoint_epoch5.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d14da734ef43353dd0295e2cf8c439dbde772a2a8c75b1089e0ae109a40cf46b
|
| 3 |
+
size 124249546
|
yolo/best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46b9db9a6deed93cb7b2322ddf61d268872b9a58911f0bde9e238218fd59da17
|
| 3 |
+
size 93125376
|