Spaces:
Sleeping
Sleeping
DariusGiannoli commited on
Commit Β·
640e5f2
1
Parent(s): 5cc06e1
fix: 5 critical bugs + dark theme
Browse files- fix yolo model path typo in config.py
- add ROI validation before locking in Data Lab
- stop on focal=0 in Stereo Geometry instead of propagating inf
- wrap PFM parsing in try/except for invalid uploads
- clamp stride max to window_size/2 in Real-Time Detection
- add dark theme with cyan accent to .streamlit/config.toml
- .streamlit/config.toml +8 -0
- pages/2_Data_Lab.py +15 -4
- pages/6_RealTime_Detection.py +1 -1
- pages/8_Stereo_Geometry.py +4 -2
- src/config.py +1 -2
.streamlit/config.toml
CHANGED
|
@@ -1,3 +1,11 @@
|
|
| 1 |
[server]
|
| 2 |
enableXsrfProtection = false
|
| 3 |
enableCORS = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
[server]
|
| 2 |
enableXsrfProtection = false
|
| 3 |
enableCORS = false
|
| 4 |
+
|
| 5 |
+
[theme]
|
| 6 |
+
base = "dark"
|
| 7 |
+
primaryColor = "#00d4ff"
|
| 8 |
+
backgroundColor = "#0e1117"
|
| 9 |
+
secondaryBackgroundColor = "#1a1f2e"
|
| 10 |
+
textColor = "#e6e6e6"
|
| 11 |
+
font = "sans serif"
|
pages/2_Data_Lab.py
CHANGED
|
@@ -100,8 +100,12 @@ with col1:
|
|
| 100 |
|
| 101 |
up_gt_l = st.file_uploader("Left Ground Truth Depth (.pfm)", type=["pfm"])
|
| 102 |
if up_gt_l:
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
with col2:
|
| 107 |
up_r = st.file_uploader("Right Image (Stereo Match)", type=["png", "jpg", "jpeg"])
|
|
@@ -112,8 +116,12 @@ with col2:
|
|
| 112 |
|
| 113 |
up_gt_r = st.file_uploader("Right Ground Truth Depth (.pfm)", type=["pfm"])
|
| 114 |
if up_gt_r:
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
# ---------------------------------------------------------------------------
|
| 119 |
# Step 2 β Full pipeline (requires all 5 files)
|
|
@@ -268,6 +276,9 @@ if up_l and up_r and up_conf and up_gt_l and up_gt_r:
|
|
| 268 |
# -----------------------------------------------------------------------
|
| 269 |
st.divider()
|
| 270 |
if st.button("π Lock Data & Proceed to Benchmark"):
|
|
|
|
|
|
|
|
|
|
| 271 |
rois_data = []
|
| 272 |
for i, roi in enumerate(st.session_state["rois"]):
|
| 273 |
rois_data.append({
|
|
|
|
| 100 |
|
| 101 |
up_gt_l = st.file_uploader("Left Ground Truth Depth (.pfm)", type=["pfm"])
|
| 102 |
if up_gt_l:
|
| 103 |
+
try:
|
| 104 |
+
gt_l_prev = read_pfm(up_gt_l.read()); up_gt_l.seek(0)
|
| 105 |
+
st.image(vis_depth(gt_l_prev), caption="Left GT Depth Preview", use_container_width=True)
|
| 106 |
+
except (ValueError, Exception) as e:
|
| 107 |
+
st.error(f"β Invalid PFM file (left): {e}")
|
| 108 |
+
up_gt_l = None
|
| 109 |
|
| 110 |
with col2:
|
| 111 |
up_r = st.file_uploader("Right Image (Stereo Match)", type=["png", "jpg", "jpeg"])
|
|
|
|
| 116 |
|
| 117 |
up_gt_r = st.file_uploader("Right Ground Truth Depth (.pfm)", type=["pfm"])
|
| 118 |
if up_gt_r:
|
| 119 |
+
try:
|
| 120 |
+
gt_r_prev = read_pfm(up_gt_r.read()); up_gt_r.seek(0)
|
| 121 |
+
st.image(vis_depth(gt_r_prev), caption="Right GT Depth Preview", use_container_width=True)
|
| 122 |
+
except (ValueError, Exception) as e:
|
| 123 |
+
st.error(f"β Invalid PFM file (right): {e}")
|
| 124 |
+
up_gt_r = None
|
| 125 |
|
| 126 |
# ---------------------------------------------------------------------------
|
| 127 |
# Step 2 β Full pipeline (requires all 5 files)
|
|
|
|
| 276 |
# -----------------------------------------------------------------------
|
| 277 |
st.divider()
|
| 278 |
if st.button("π Lock Data & Proceed to Benchmark"):
|
| 279 |
+
if not st.session_state.get("rois") or len(st.session_state["rois"]) == 0:
|
| 280 |
+
st.error("β Define at least one ROI before locking!")
|
| 281 |
+
st.stop()
|
| 282 |
rois_data = []
|
| 283 |
for i, roi in enumerate(st.session_state["rois"]):
|
| 284 |
rois_data.append({
|
pages/6_RealTime_Detection.py
CHANGED
|
@@ -159,7 +159,7 @@ def rce_feature_fn(patch_bgr):
|
|
| 159 |
# ===================================================================
|
| 160 |
st.subheader("Sliding Window Parameters")
|
| 161 |
p1, p2, p3 = st.columns(3)
|
| 162 |
-
stride = p1.slider("Stride (px)", 4, max(win_w,
|
| 163 |
max(win_w // 4, 4), step=2,
|
| 164 |
help="Lower = more windows = slower but finer")
|
| 165 |
conf_thresh = p2.slider("Confidence Threshold", 0.5, 1.0, 0.7, 0.05)
|
|
|
|
| 159 |
# ===================================================================
|
| 160 |
st.subheader("Sliding Window Parameters")
|
| 161 |
p1, p2, p3 = st.columns(3)
|
| 162 |
+
stride = p1.slider("Stride (px)", 4, max(win_w // 2, 4),
|
| 163 |
max(win_w // 4, 4), step=2,
|
| 164 |
help="Lower = more windows = slower but finer")
|
| 165 |
conf_thresh = p2.slider("Confidence Threshold", 0.5, 1.0, 0.7, 0.05)
|
pages/8_Stereo_Geometry.py
CHANGED
|
@@ -69,8 +69,10 @@ baseline = float(calib.get("baseline", 1.0))
|
|
| 69 |
ndisp = int(calib.get("ndisp", 128))
|
| 70 |
|
| 71 |
if focal <= 0:
|
| 72 |
-
st.
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
st.subheader("Camera Calibration")
|
| 76 |
cc1, cc2, cc3, cc4 = st.columns(4)
|
|
|
|
| 69 |
ndisp = int(calib.get("ndisp", 128))
|
| 70 |
|
| 71 |
if focal <= 0:
|
| 72 |
+
st.error("β Focal length is **0** β the camera config is missing or malformed. "
|
| 73 |
+
"Depth estimation cannot proceed. Return to **Data Lab** and upload a valid "
|
| 74 |
+
"Middlebury camera config.")
|
| 75 |
+
st.stop()
|
| 76 |
|
| 77 |
st.subheader("Camera Calibration")
|
| 78 |
cc1, cc2, cc3, cc4 = st.columns(4)
|
src/config.py
CHANGED
|
@@ -13,8 +13,7 @@ BIRD_YAML = BIRD_YOLO_DIR / "bird_data.yaml"
|
|
| 13 |
# Model Paths
|
| 14 |
MODEL_DIR = PROJECT_ROOT / "models"
|
| 15 |
MODEL_PATHS = {
|
| 16 |
-
|
| 17 |
-
'yolo' : PROJECT_ROOT / "volov8n.pt",
|
| 18 |
'resnet': MODEL_DIR / "resnet18.pth",
|
| 19 |
'resnet_head': MODEL_DIR / "resnet18_head.pkl",
|
| 20 |
'mobilenet': MODEL_DIR / "mobilenet_v3.pth",
|
|
|
|
| 13 |
# Model Paths
|
| 14 |
MODEL_DIR = PROJECT_ROOT / "models"
|
| 15 |
MODEL_PATHS = {
|
| 16 |
+
'yolo' : MODEL_DIR / "yolov8n.pt",
|
|
|
|
| 17 |
'resnet': MODEL_DIR / "resnet18.pth",
|
| 18 |
'resnet_head': MODEL_DIR / "resnet18_head.pkl",
|
| 19 |
'mobilenet': MODEL_DIR / "mobilenet_v3.pth",
|