Spaces:
Sleeping
Sleeping
vishalkatheriya18
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -15,18 +15,15 @@ def predict_with_yolo(image):
|
|
15 |
# Run inference on the image using the YOLO model
|
16 |
results = st.session_state.yolo_model(image)
|
17 |
|
18 |
-
#
|
19 |
-
predictions = []
|
20 |
if results:
|
|
|
21 |
for result in results:
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
"Confidence": confidence
|
28 |
-
})
|
29 |
-
return predictions
|
30 |
|
31 |
# Streamlit app UI
|
32 |
st.title("Clothing Detection with YOLO")
|
@@ -46,9 +43,7 @@ if url:
|
|
46 |
|
47 |
# Display predictions
|
48 |
if predictions:
|
49 |
-
st.write("Predictions:")
|
50 |
-
for pred in predictions:
|
51 |
-
st.write(f"Class: {pred['Class']}, Confidence: {pred['Confidence']:.2f}")
|
52 |
else:
|
53 |
st.write("No objects detected.")
|
54 |
|
|
|
15 |
# Run inference on the image using the YOLO model
|
16 |
results = st.session_state.yolo_model(image)
|
17 |
|
18 |
+
# Print the classification results
|
|
|
19 |
if results:
|
20 |
+
# YOLOv8 classification results contain label and confidence for the whole image
|
21 |
for result in results:
|
22 |
+
# print(f"Class: {result.names[result.probs.top1]}, Confidence: {result.probs.top1conf:.2f}")
|
23 |
+
return {"Class":result.names[result.probs.top1],"Confidence":result.probs.top1conf:.2f}
|
24 |
+
else:
|
25 |
+
print("No classification results found.")
|
26 |
+
|
|
|
|
|
|
|
27 |
|
28 |
# Streamlit app UI
|
29 |
st.title("Clothing Detection with YOLO")
|
|
|
43 |
|
44 |
# Display predictions
|
45 |
if predictions:
|
46 |
+
st.write("Predictions:",predictions)
|
|
|
|
|
47 |
else:
|
48 |
st.write("No objects detected.")
|
49 |
|