Update app.py
Browse files
app.py
CHANGED
|
@@ -34,6 +34,24 @@ except Exception as e:
|
|
| 34 |
st.title("YOLOv11 Object Detection")
|
| 35 |
st.write("Upload an image and let the model detect objects.")
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
| 38 |
if uploaded_file:
|
| 39 |
# Read and display the image
|
|
@@ -43,7 +61,11 @@ if uploaded_file:
|
|
| 43 |
# Perform prediction
|
| 44 |
with st.spinner("Processing..."):
|
| 45 |
try:
|
| 46 |
-
results = model.predict(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
st.write("Detection Results:")
|
| 48 |
st.image(results[0].plot(), caption="Detections", use_column_width=True)
|
| 49 |
except Exception as e:
|
|
|
|
| 34 |
st.title("YOLOv11 Object Detection")
|
| 35 |
st.write("Upload an image and let the model detect objects.")
|
| 36 |
|
| 37 |
+
# Sliders for Confidence and Overlap thresholds
|
| 38 |
+
confidence_threshold = st.slider(
|
| 39 |
+
"Confidence Threshold",
|
| 40 |
+
min_value=0.0,
|
| 41 |
+
max_value=1.0,
|
| 42 |
+
value=0.25,
|
| 43 |
+
step=0.01,
|
| 44 |
+
help="Set the minimum confidence score for detections.",
|
| 45 |
+
)
|
| 46 |
+
overlap_threshold = st.slider(
|
| 47 |
+
"Overlap Threshold",
|
| 48 |
+
min_value=0.0,
|
| 49 |
+
max_value=1.0,
|
| 50 |
+
value=0.45,
|
| 51 |
+
step=0.01,
|
| 52 |
+
help="Set the maximum allowable overlap for non-max suppression.",
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
| 56 |
if uploaded_file:
|
| 57 |
# Read and display the image
|
|
|
|
| 61 |
# Perform prediction
|
| 62 |
with st.spinner("Processing..."):
|
| 63 |
try:
|
| 64 |
+
results = model.predict(
|
| 65 |
+
np.array(image),
|
| 66 |
+
conf=confidence_threshold, # Set confidence threshold
|
| 67 |
+
iou=overlap_threshold, # Set overlap (IoU) threshold
|
| 68 |
+
)
|
| 69 |
st.write("Detection Results:")
|
| 70 |
st.image(results[0].plot(), caption="Detections", use_column_width=True)
|
| 71 |
except Exception as e:
|