Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -137,7 +137,7 @@ CONFIGS = {
|
|
| 137 |
'model_path': 'best_upright.onnx',
|
| 138 |
'yaml_path': 'data_upright.yaml',
|
| 139 |
'input_size': 640,
|
| 140 |
-
'confidence_threshold': 0.
|
| 141 |
'nms_threshold': 0.45
|
| 142 |
}
|
| 143 |
}
|
|
@@ -179,6 +179,7 @@ class ModelManager:
|
|
| 179 |
|
| 180 |
# Load model dengan available backend
|
| 181 |
session = None
|
|
|
|
| 182 |
|
| 183 |
if ONNX_AVAILABLE and ort is not None:
|
| 184 |
# Load ONNX session dengan CPU optimization
|
|
@@ -194,6 +195,18 @@ class ModelManager:
|
|
| 194 |
providers=providers,
|
| 195 |
sess_options=session_options
|
| 196 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
else:
|
| 198 |
# For now, only ONNX Runtime is supported for model loading
|
| 199 |
# PyTorch/TensorFlow alternatives would need model conversion
|
|
@@ -208,7 +221,7 @@ class ModelManager:
|
|
| 208 |
'session': session,
|
| 209 |
'class_names': class_names,
|
| 210 |
'input_name': session.get_inputs()[0].name,
|
| 211 |
-
'input_size':
|
| 212 |
'confidence': config['confidence_threshold'],
|
| 213 |
'nms': config.get('nms_threshold', 0.45)
|
| 214 |
}
|
|
|
|
| 137 |
'model_path': 'best_upright.onnx',
|
| 138 |
'yaml_path': 'data_upright.yaml',
|
| 139 |
'input_size': 640,
|
| 140 |
+
'confidence_threshold': 0.5, # 🔧 Match test script confidence (was 0.25)
|
| 141 |
'nms_threshold': 0.45
|
| 142 |
}
|
| 143 |
}
|
|
|
|
| 179 |
|
| 180 |
# Load model dengan available backend
|
| 181 |
session = None
|
| 182 |
+
actual_input_size = config['input_size'] # Default fallback
|
| 183 |
|
| 184 |
if ONNX_AVAILABLE and ort is not None:
|
| 185 |
# Load ONNX session dengan CPU optimization
|
|
|
|
| 195 |
providers=providers,
|
| 196 |
sess_options=session_options
|
| 197 |
)
|
| 198 |
+
|
| 199 |
+
# 🔧 AUTO-DETECT input size dari model shape (fix untuk upright model)
|
| 200 |
+
try:
|
| 201 |
+
input_shape = session.get_inputs()[0].shape
|
| 202 |
+
if isinstance(input_shape, (list, tuple)) and len(input_shape) >= 4:
|
| 203 |
+
h, w = input_shape[2], input_shape[3]
|
| 204 |
+
if isinstance(h, int) and isinstance(w, int) and h > 0 and w > 0:
|
| 205 |
+
actual_input_size = h # gunakan height dari model shape
|
| 206 |
+
logger.info(f"🔧 AUTO-DETECTED input size untuk {config_key}: {actual_input_size} (was {config['input_size']})")
|
| 207 |
+
except Exception as e:
|
| 208 |
+
logger.warning(f"⚠️ Failed to auto-detect input size for {config_key}: {e}")
|
| 209 |
+
# Keep using config input_size as fallback
|
| 210 |
else:
|
| 211 |
# For now, only ONNX Runtime is supported for model loading
|
| 212 |
# PyTorch/TensorFlow alternatives would need model conversion
|
|
|
|
| 221 |
'session': session,
|
| 222 |
'class_names': class_names,
|
| 223 |
'input_name': session.get_inputs()[0].name,
|
| 224 |
+
'input_size': actual_input_size, # 🔧 Gunakan auto-detected input size
|
| 225 |
'confidence': config['confidence_threshold'],
|
| 226 |
'nms': config.get('nms_threshold', 0.45)
|
| 227 |
}
|