Zhen Ye commited on
Commit
6144c58
·
1 Parent(s): 18ba97a

fixed depth norm

Browse files
Files changed (1) hide show
  1. inference.py +6 -1
inference.py CHANGED
@@ -432,7 +432,7 @@ def process_frames_depth(
432
  logging.debug("Computed depth for frame %d/%d", idx + 1, len(frames))
433
 
434
  # Compute global min/max (using percentiles to handle outliers)
435
- all_depths = np.concatenate(all_values)
436
 
437
  # Filter out NaN and inf values
438
  valid_depths = all_depths[np.isfinite(all_depths)]
@@ -445,6 +445,11 @@ def process_frames_depth(
445
  global_min = float(np.percentile(valid_depths, 1)) # 1st percentile to clip outliers
446
  global_max = float(np.percentile(valid_depths, 99)) # 99th percentile
447
 
 
 
 
 
 
448
  # Handle edge case where min == max
449
  if abs(global_max - global_min) < 1e-6:
450
  global_min = float(valid_depths.min())
 
432
  logging.debug("Computed depth for frame %d/%d", idx + 1, len(frames))
433
 
434
  # Compute global min/max (using percentiles to handle outliers)
435
+ all_depths = np.concatenate(all_values).astype(np.float32, copy=False)
436
 
437
  # Filter out NaN and inf values
438
  valid_depths = all_depths[np.isfinite(all_depths)]
 
445
  global_min = float(np.percentile(valid_depths, 1)) # 1st percentile to clip outliers
446
  global_max = float(np.percentile(valid_depths, 99)) # 99th percentile
447
 
448
+ if not np.isfinite(global_min) or not np.isfinite(global_max):
449
+ logging.warning("Depth percentiles are non-finite - using min/max fallback")
450
+ global_min = float(valid_depths.min())
451
+ global_max = float(valid_depths.max())
452
+
453
  # Handle edge case where min == max
454
  if abs(global_max - global_min) < 1e-6:
455
  global_min = float(valid_depths.min())