Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,20 @@ import streamlit as st
|
|
2 |
from ultralytics import YOLO
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
|
|
5 |
|
6 |
-
#
|
7 |
-
model_path = "best.pt" #
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
try:
|
9 |
model = YOLO(model_path)
|
10 |
-
except
|
11 |
-
st.error(f"
|
12 |
|
13 |
# Streamlit app
|
14 |
st.title("YOLOv11 Object Detection")
|
@@ -27,4 +34,4 @@ if uploaded_file:
|
|
27 |
st.write("Detection Results:")
|
28 |
st.image(results[0].plot(), caption="Detections", use_column_width=True)
|
29 |
except Exception as e:
|
30 |
-
st.error(f"
|
|
|
2 |
from ultralytics import YOLO
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
+
import os
|
6 |
|
7 |
+
# Define the model path
|
8 |
+
model_path = "best.pt" # Assumes `best.pt` is in the root directory
|
9 |
+
|
10 |
+
# Verify file existence
|
11 |
+
if not os.path.exists(model_path):
|
12 |
+
st.error(f"Model file not found at: {model_path}. Current directory files: {os.listdir()}")
|
13 |
+
|
14 |
+
# Load the YOLO model
|
15 |
try:
|
16 |
model = YOLO(model_path)
|
17 |
+
except Exception as e:
|
18 |
+
st.error(f"Error loading model: {e}")
|
19 |
|
20 |
# Streamlit app
|
21 |
st.title("YOLOv11 Object Detection")
|
|
|
34 |
st.write("Detection Results:")
|
35 |
st.image(results[0].plot(), caption="Detections", use_column_width=True)
|
36 |
except Exception as e:
|
37 |
+
st.error(f"E
|