Spaces:
Running
Running
Update ui_components.py
Browse files- ui_components.py +15 -10
ui_components.py
CHANGED
|
@@ -5,7 +5,7 @@ UI components for the Streamlit application
|
|
| 5 |
import streamlit as st
|
| 6 |
from typing import Dict, List, Any, Optional
|
| 7 |
from local_models import get_local_model_manager
|
| 8 |
-
|
| 9 |
|
| 10 |
# Available Hugging Face models for remote API
|
| 11 |
AVAILABLE_MODELS = {
|
|
@@ -264,18 +264,23 @@ def _render_model_output(result: Dict[str, Any]):
|
|
| 264 |
|
| 265 |
|
| 266 |
def _render_person_detection_result(detection: Dict[str, Any]):
|
| 267 |
-
"""Render person on track detection specific results"""
|
| 268 |
-
people_count = detection.get('people_count', 0)
|
| 269 |
-
confidence = detection.get('confidence', 0)
|
| 270 |
analysis = detection.get('analysis', 'No analysis')
|
| 271 |
-
|
| 272 |
st.write(f"**Detection Analysis:** {analysis}")
|
| 273 |
-
|
| 274 |
-
#
|
| 275 |
-
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
st.metric("👥 People Detected", people_count)
|
| 278 |
-
with col2:
|
| 279 |
st.metric("📊 Model Confidence", f"{confidence:.0%}")
|
| 280 |
|
| 281 |
|
|
|
|
| 5 |
import streamlit as st
|
| 6 |
from typing import Dict, List, Any, Optional
|
| 7 |
from local_models import get_local_model_manager
|
| 8 |
+
from streamlit.errors import StreamlitAPIException # am Datei-Anfang (falls noch nicht da)
|
| 9 |
|
| 10 |
# Available Hugging Face models for remote API
|
| 11 |
AVAILABLE_MODELS = {
|
|
|
|
| 264 |
|
| 265 |
|
| 266 |
def _render_person_detection_result(detection: Dict[str, Any]):
|
| 267 |
+
"""Render person on track detection specific results (robust ohne tiefe Column-Nesting)"""
|
| 268 |
+
people_count = int(detection.get('people_count', 0))
|
| 269 |
+
confidence = float(detection.get('confidence', 0.0))
|
| 270 |
analysis = detection.get('analysis', 'No analysis')
|
| 271 |
+
|
| 272 |
st.write(f"**Detection Analysis:** {analysis}")
|
| 273 |
+
|
| 274 |
+
# Versuche 2-Spalten-Layout; wenn wir schon in einer Column sind (nested), fallback auf vertikal
|
| 275 |
+
try:
|
| 276 |
+
col1, col2 = st.columns(2)
|
| 277 |
+
with col1:
|
| 278 |
+
st.metric("👥 People Detected", people_count)
|
| 279 |
+
with col2:
|
| 280 |
+
st.metric("📊 Model Confidence", f"{confidence:.0%}")
|
| 281 |
+
except StreamlitAPIException:
|
| 282 |
+
# Fallback ohne zusätzliche Columns (vermeidet die Nesting-Exception)
|
| 283 |
st.metric("👥 People Detected", people_count)
|
|
|
|
| 284 |
st.metric("📊 Model Confidence", f"{confidence:.0%}")
|
| 285 |
|
| 286 |
|