danielhshi8224 commited on
Commit
ef39fc3
·
1 Parent(s): a063f92
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -176,22 +176,34 @@ def detect_objects_batch(files, conf=0.25, iou=0.25):
176
 
177
  for f in files[:MAX_BATCH]:
178
  path = _ensure_path(f)
 
179
  try:
180
- # Diagnostic: show resolved path and file info
181
- try:
182
- exists = os.path.exists(path)
183
- size = os.path.getsize(path) if exists else None
184
- except Exception:
185
- exists = False
186
- size = None
187
- print(f"[DETECT] resolved path={path!r}, exists={exists}, size={size}")
188
  except Exception:
189
- pass
 
 
 
 
 
 
 
 
 
190
  try:
191
  results = ymodel.predict(source=path, conf=conf, iou=iou, imgsz=640, verbose=False)
192
  except Exception as e:
193
- print(f"Detection failed for {path}:", e)
 
 
 
 
 
 
 
194
  continue
 
195
  res = results[0]
196
 
197
  # annotated image
 
176
 
177
  for f in files[:MAX_BATCH]:
178
  path = _ensure_path(f)
179
+ # Diagnostic: show resolved path and file info
180
  try:
181
+ exists = os.path.exists(path)
182
+ size = os.path.getsize(path) if exists else None
 
 
 
 
 
 
183
  except Exception:
184
+ exists = False
185
+ size = None
186
+ print(f"[DETECT] resolved path={path!r}, exists={exists}, size={size}")
187
+ # Try opening with PIL to ensure file is a readable image
188
+ try:
189
+ with Image.open(path) as _img:
190
+ print(f"[DETECT] PIL can open file: format={_img.format}, size={_img.size}")
191
+ except Exception as pil_e:
192
+ print(f"[DETECT] PIL failed to open file before predict: {pil_e}")
193
+
194
  try:
195
  results = ymodel.predict(source=path, conf=conf, iou=iou, imgsz=640, verbose=False)
196
  except Exception as e:
197
+ import traceback
198
+ print(f"[DETECT] Detection failed for {path}: {e}")
199
+ traceback.print_exc()
200
+ # Also print type/info about the model and source
201
+ try:
202
+ print(f"[DETECT] model type={type(ymodel)}, model_repr={repr(ymodel)[:200]}")
203
+ except Exception:
204
+ pass
205
  continue
206
+
207
  res = results[0]
208
 
209
  # annotated image