MogensR commited on
Commit
96de0be
·
1 Parent(s): 6259fe6
Files changed (1) hide show
  1. models/matanyone_loader.py +0 -23
models/matanyone_loader.py CHANGED
@@ -872,26 +872,3 @@ def _flush_chunk(self, frames_bgr, seed_1hw, alpha_writer, fg_writer):
872
  log.error(error_msg, exc_info=True)
873
  raise MatAnyError(error_msg) from e
874
 
875
- # Normalize to numpy list of HW float32 [0,1]
876
- if isinstance(alphas, torch.Tensor):
877
- alphas_np = alphas.detach().float().clamp(0, 1).cpu().numpy()
878
- else:
879
- alphas_np = np.asarray(alphas)
880
- if alphas_np.max() > 1.0:
881
- alphas_np = (alphas_np / 255.0).clip(0, 1)
882
-
883
- if alphas_np.ndim == 3:
884
- T, H, W = alphas_np.shape
885
- pass
886
- elif alphas_np.ndim == 4 and alphas_np.shape[1] in (1, 3):
887
- # Possibly T,1,H,W — squeeze channel
888
- alphas_np = np.squeeze(alphas_np, axis=1) if alphas_np.shape[1] == 1 else np.mean(alphas_np, axis=1)
889
- else:
890
- raise MatAnyError(f"Unexpected alphas shape from process_video: {alphas_np.shape}")
891
-
892
- for f_bgr, a_hw in zip(frames_bgr, alphas_np):
893
- a_u8 = (a_hw * 255.0 + 0.5).astype(np.uint8)
894
- a_rgb = cv2.cvtColor(a_u8, cv2.COLOR_GRAY2BGR)
895
- fg_bgr = (f_bgr.astype(np.float32) * (a_hw[..., None])).clip(0, 255).astype(np.uint8)
896
- alpha_writer.write(a_rgb)
897
- fg_writer.write(fg_bgr)
 
872
  log.error(error_msg, exc_info=True)
873
  raise MatAnyError(error_msg) from e
874