Mai Phuoc Minh Tai commited on
Commit
9e93b8c
·
1 Parent(s): 4a8eb31

fix: Add HuggingFace Docker model paths and debug logging for YOLO loading

Browse files
Files changed (1) hide show
  1. src/models/ensemble.py +10 -2
src/models/ensemble.py CHANGED
@@ -77,17 +77,25 @@ class EnsembleDetector:
77
 
78
  # Determine model path
79
  if model_path is None:
80
- # Try multiple possible paths
81
  possible_paths = [
82
- "../models/yolo11base.pt",
 
83
  "models/yolo11base.pt",
 
 
 
84
  os.path.join(os.path.dirname(__file__), "../../../models/yolo11base.pt"),
85
  "D:/Gitrepo/road-damage/models/yolo11base.pt",
86
  ]
 
87
  for path in possible_paths:
88
  if os.path.exists(path):
89
  model_path = path
 
90
  break
 
 
91
 
92
  # Load model
93
  if YOLO_AVAILABLE and model_path and os.path.exists(model_path):
 
77
 
78
  # Determine model path
79
  if model_path is None:
80
+ # Try multiple possible paths (local dev + HuggingFace Docker)
81
  possible_paths = [
82
+ # HuggingFace Docker container paths (WORKDIR=/app)
83
+ "/app/models/yolo11base.pt",
84
  "models/yolo11base.pt",
85
+ # Local development paths
86
+ "../models/yolo11base.pt",
87
+ os.path.join(os.path.dirname(__file__), "../../models/yolo11base.pt"),
88
  os.path.join(os.path.dirname(__file__), "../../../models/yolo11base.pt"),
89
  "D:/Gitrepo/road-damage/models/yolo11base.pt",
90
  ]
91
+ print(f"[MODEL] Searching for model in paths: {possible_paths}")
92
  for path in possible_paths:
93
  if os.path.exists(path):
94
  model_path = path
95
+ print(f"[MODEL] Found model at: {path}")
96
  break
97
+ if model_path is None:
98
+ print(f"[MODEL] WARNING: Model not found in any path!")
99
 
100
  # Load model
101
  if YOLO_AVAILABLE and model_path and os.path.exists(model_path):