Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -597,7 +597,7 @@ of **25 COCO classes**. It brings together:
|
|
| 597 |
cols = st.columns(min(3, len(imgs)))
|
| 598 |
for i, img_path in enumerate(imgs[:3]):
|
| 599 |
with cols[i]:
|
| 600 |
-
st.image(img_path, caption=os.path.basename(img_path), width=
|
| 601 |
else:
|
| 602 |
st.info("No sample images found in `inference_outputs/` yet.")
|
| 603 |
else:
|
|
@@ -620,7 +620,7 @@ The app will run **all 4 CNN models** and show **top-5 predictions** per model.
|
|
| 620 |
|
| 621 |
if uploaded_file is not None:
|
| 622 |
pil_img = read_image_file(uploaded_file)
|
| 623 |
-
st.image(pil_img, caption="Uploaded image", width=
|
| 624 |
|
| 625 |
with st.spinner("Loading classification models..."):
|
| 626 |
cls_models = load_classification_models()
|
|
@@ -676,7 +676,7 @@ YOLOv8 will detect all objects and optionally verify them with the best classifi
|
|
| 676 |
pil_img = read_image_file(uploaded_file)
|
| 677 |
|
| 678 |
# β REMOVE THIS (caused duplicate)
|
| 679 |
-
# st.image(pil_img, caption="Uploaded image", width=
|
| 680 |
|
| 681 |
with st.spinner("Loading YOLO model..."):
|
| 682 |
yolo_model = load_yolo_model()
|
|
@@ -709,10 +709,10 @@ YOLOv8 will detect all objects and optionally verify them with the best classifi
|
|
| 709 |
col1, col2 = st.columns(2)
|
| 710 |
|
| 711 |
with col1:
|
| 712 |
-
st.image(pil_img, caption="Uploaded Image", width=
|
| 713 |
|
| 714 |
with col2:
|
| 715 |
-
st.image(result["annotated_image"], caption="Detected Result", width=
|
| 716 |
|
| 717 |
st.write(f"YOLO inference time: {result['yolo_inference_time_sec']*1000:.1f} ms")
|
| 718 |
st.write(f"Number of detections: {len(result['detections'])}")
|
|
@@ -729,7 +729,7 @@ YOLOv8 will detect all objects and optionally verify them with the best classifi
|
|
| 729 |
}
|
| 730 |
for det in result["detections"]
|
| 731 |
])
|
| 732 |
-
st.dataframe(df_det, width=
|
| 733 |
|
| 734 |
# ------------------------------------------------------------
|
| 735 |
# PAGE 4 β MODEL PERFORMANCE
|
|
@@ -743,24 +743,24 @@ elif page == "π Model Performance":
|
|
| 743 |
if df_cls.empty:
|
| 744 |
st.info("No classification metrics found yet in `smartvision_metrics/`.")
|
| 745 |
else:
|
| 746 |
-
st.dataframe(df_cls, width=
|
| 747 |
|
| 748 |
col1, col2 = st.columns(2)
|
| 749 |
with col1:
|
| 750 |
st.bar_chart(
|
| 751 |
df_cls.set_index("Model")["Accuracy"],
|
| 752 |
-
width=
|
| 753 |
)
|
| 754 |
with col2:
|
| 755 |
st.bar_chart(
|
| 756 |
df_cls.set_index("Model")["F1 (weighted)"],
|
| 757 |
-
width=
|
| 758 |
)
|
| 759 |
|
| 760 |
st.markdown("#### Inference Speed (images/sec)")
|
| 761 |
st.bar_chart(
|
| 762 |
df_cls.set_index("Model")["Images/sec"],
|
| 763 |
-
width=
|
| 764 |
)
|
| 765 |
|
| 766 |
# --- YOLO metrics ---
|
|
@@ -791,7 +791,7 @@ elif page == "π Model Performance":
|
|
| 791 |
]
|
| 792 |
if imgs:
|
| 793 |
for img in sorted(imgs):
|
| 794 |
-
st.image(img, caption=os.path.basename(img), width=
|
| 795 |
else:
|
| 796 |
st.info("No comparison plots found in `smartvision_metrics/comparison_plots/`.")
|
| 797 |
else:
|
|
@@ -831,7 +831,7 @@ from your webcam and run YOLOv8 detection on it.
|
|
| 831 |
conf_threshold=conf_th,
|
| 832 |
)
|
| 833 |
|
| 834 |
-
st.image(result["annotated_image"], caption="Detections", width=
|
| 835 |
st.write(f"YOLO inference time: {result['yolo_inference_time_sec']*1000:.1f} ms")
|
| 836 |
st.write(f"Number of detections: {len(result['detections'])}")
|
| 837 |
|
|
|
|
| 597 |
cols = st.columns(min(3, len(imgs)))
|
| 598 |
for i, img_path in enumerate(imgs[:3]):
|
| 599 |
with cols[i]:
|
| 600 |
+
st.image(img_path, caption=os.path.basename(img_path), width=520)
|
| 601 |
else:
|
| 602 |
st.info("No sample images found in `inference_outputs/` yet.")
|
| 603 |
else:
|
|
|
|
| 620 |
|
| 621 |
if uploaded_file is not None:
|
| 622 |
pil_img = read_image_file(uploaded_file)
|
| 623 |
+
st.image(pil_img, caption="Uploaded image", width=520)
|
| 624 |
|
| 625 |
with st.spinner("Loading classification models..."):
|
| 626 |
cls_models = load_classification_models()
|
|
|
|
| 676 |
pil_img = read_image_file(uploaded_file)
|
| 677 |
|
| 678 |
# β REMOVE THIS (caused duplicate)
|
| 679 |
+
# st.image(pil_img, caption="Uploaded image", width=520)
|
| 680 |
|
| 681 |
with st.spinner("Loading YOLO model..."):
|
| 682 |
yolo_model = load_yolo_model()
|
|
|
|
| 709 |
col1, col2 = st.columns(2)
|
| 710 |
|
| 711 |
with col1:
|
| 712 |
+
st.image(pil_img, caption="Uploaded Image", width=520)
|
| 713 |
|
| 714 |
with col2:
|
| 715 |
+
st.image(result["annotated_image"], caption="Detected Result", width=520)
|
| 716 |
|
| 717 |
st.write(f"YOLO inference time: {result['yolo_inference_time_sec']*1000:.1f} ms")
|
| 718 |
st.write(f"Number of detections: {len(result['detections'])}")
|
|
|
|
| 729 |
}
|
| 730 |
for det in result["detections"]
|
| 731 |
])
|
| 732 |
+
st.dataframe(df_det, width=520)
|
| 733 |
|
| 734 |
# ------------------------------------------------------------
|
| 735 |
# PAGE 4 β MODEL PERFORMANCE
|
|
|
|
| 743 |
if df_cls.empty:
|
| 744 |
st.info("No classification metrics found yet in `smartvision_metrics/`.")
|
| 745 |
else:
|
| 746 |
+
st.dataframe(df_cls, width=520)
|
| 747 |
|
| 748 |
col1, col2 = st.columns(2)
|
| 749 |
with col1:
|
| 750 |
st.bar_chart(
|
| 751 |
df_cls.set_index("Model")["Accuracy"],
|
| 752 |
+
width=520,
|
| 753 |
)
|
| 754 |
with col2:
|
| 755 |
st.bar_chart(
|
| 756 |
df_cls.set_index("Model")["F1 (weighted)"],
|
| 757 |
+
width=520,
|
| 758 |
)
|
| 759 |
|
| 760 |
st.markdown("#### Inference Speed (images/sec)")
|
| 761 |
st.bar_chart(
|
| 762 |
df_cls.set_index("Model")["Images/sec"],
|
| 763 |
+
width=520,
|
| 764 |
)
|
| 765 |
|
| 766 |
# --- YOLO metrics ---
|
|
|
|
| 791 |
]
|
| 792 |
if imgs:
|
| 793 |
for img in sorted(imgs):
|
| 794 |
+
st.image(img, caption=os.path.basename(img), width=520)
|
| 795 |
else:
|
| 796 |
st.info("No comparison plots found in `smartvision_metrics/comparison_plots/`.")
|
| 797 |
else:
|
|
|
|
| 831 |
conf_threshold=conf_th,
|
| 832 |
)
|
| 833 |
|
| 834 |
+
st.image(result["annotated_image"], caption="Detections", width=520)
|
| 835 |
st.write(f"YOLO inference time: {result['yolo_inference_time_sec']*1000:.1f} ms")
|
| 836 |
st.write(f"Number of detections: {len(result['detections'])}")
|
| 837 |
|