Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,8 +27,11 @@ if uploaded_file:
|
|
27 |
image = Image.open(uploaded_file)
|
28 |
image_np = np.array(image)
|
29 |
|
|
|
|
|
|
|
|
|
30 |
# Run inference
|
31 |
-
st.write("Running inference...")
|
32 |
results = model.predict(source=image_np, conf=0.5)
|
33 |
|
34 |
# Annotate image
|
@@ -39,11 +42,5 @@ if uploaded_file:
|
|
39 |
# Convert annotated image for Streamlit
|
40 |
if annotated_image is not None:
|
41 |
annotated_image_rgb = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
42 |
-
|
43 |
-
|
44 |
-
# Display bounding boxes and confidence scores
|
45 |
-
st.write("Detection Results:")
|
46 |
-
for result in results:
|
47 |
-
for box in result.boxes.data.cpu().numpy():
|
48 |
-
x1, y1, x2, y2, conf, cls = box
|
49 |
-
st.write(f"Class: {int(cls)}, Confidence: {conf:.2f}, Box: [{x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f}]")
|
|
|
27 |
image = Image.open(uploaded_file)
|
28 |
image_np = np.array(image)
|
29 |
|
30 |
+
# Display "Running inference..." in red
|
31 |
+
placeholder = st.empty()
|
32 |
+
placeholder.markdown('<h3 style="color: red;">Running inference...</h3>', unsafe_allow_html=True)
|
33 |
+
|
34 |
# Run inference
|
|
|
35 |
results = model.predict(source=image_np, conf=0.5)
|
36 |
|
37 |
# Annotate image
|
|
|
42 |
# Convert annotated image for Streamlit
|
43 |
if annotated_image is not None:
|
44 |
annotated_image_rgb = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
45 |
+
placeholder.empty() # Remove the "Running inference..." message
|
46 |
+
st.image(annotated_image_rgb, caption="Prediction Results", use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|