Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,17 +15,17 @@ if uploaded_file is not None:
|
|
| 15 |
image = Image.open(uploaded_file)
|
| 16 |
|
| 17 |
# Inference
|
| 18 |
-
results = model
|
| 19 |
|
| 20 |
# Display the image with bounding boxes
|
| 21 |
st.image(image, channels="RGB", caption="Object Detection Result", use_column_width=True)
|
| 22 |
|
| 23 |
# Display probability and class for each box
|
| 24 |
-
for det in results
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
# Draw box on the image
|
| 30 |
-
st.image(model.plot([image], boxes=[box], labels=[
|
| 31 |
channels="RGB", caption=f"Class {label} - Confidence: {score:.2f}", use_column_width=True)
|
|
|
|
| 15 |
image = Image.open(uploaded_file)
|
| 16 |
|
| 17 |
# Inference
|
| 18 |
+
results = model(image)
|
| 19 |
|
| 20 |
# Display the image with bounding boxes
|
| 21 |
st.image(image, channels="RGB", caption="Object Detection Result", use_column_width=True)
|
| 22 |
|
| 23 |
# Display probability and class for each box
|
| 24 |
+
for det in results:
|
| 25 |
+
box = det.boxes.xyxy
|
| 26 |
+
cls = det.boxes.cls
|
| 27 |
+
score = det.boxes.conf
|
| 28 |
|
| 29 |
# Draw box on the image
|
| 30 |
+
st.image(model.plot([image], boxes=[box], labels=[cls], confidences=[score])[0],
|
| 31 |
channels="RGB", caption=f"Class {label} - Confidence: {score:.2f}", use_column_width=True)
|