someone-in-the-world Claude Sonnet 5 commited on
Commit
e7c7a36
·
1 Parent(s): 97e9c44

Fix print_frames_info logging garbage bound-method reprs for tensor frames

Browse files

torch.Tensor has .size()/.mode() methods with the same names as PIL
Image's .size/.mode attributes, which print_frames_info reads via
getattr assuming a PIL Image. Since #53 the RIFE->upscale tensor
handoff can pass a tensor frame list to this same logging call,
producing e.g. "pil_size=<built-in method size of Tensor object at
0x...>" in production logs instead of a clean None.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Files changed (1) hide show
  1. logging_utils.py +7 -2
logging_utils.py CHANGED
@@ -71,8 +71,13 @@ def print_frames_info(label: str, frames: Any, fps: Any) -> None:
71
  kind = type(first).__name__ if first is not None else "n/a"
72
  shape = getattr(first, "shape", None)
73
  dtype = getattr(first, "dtype", None)
74
- size = getattr(first, "size", None) # PIL Image
75
- mode = getattr(first, "mode", None) # PIL Image
 
 
 
 
 
76
  print(
77
  f"[export] {label}: n={n}, fps={fps}, frame_type={kind}, shape={shape}, dtype={dtype}, "
78
  f"pil_size={size}, pil_mode={mode}",
 
71
  kind = type(first).__name__ if first is not None else "n/a"
72
  shape = getattr(first, "shape", None)
73
  dtype = getattr(first, "dtype", None)
74
+ # PIL Image exposes .size/.mode as plain attributes; torch.Tensor happens to have same-named
75
+ # *methods* (Tensor.size(), Tensor.mode()) — skip those so callers passing tensors (e.g. the
76
+ # RIFE->upscale GPU handoff) don't log a garbage bound-method repr in their place.
77
+ size = getattr(first, "size", None)
78
+ size = size if not callable(size) else None
79
+ mode = getattr(first, "mode", None)
80
+ mode = mode if not callable(mode) else None
81
  print(
82
  f"[export] {label}: n={n}, fps={fps}, frame_type={kind}, shape={shape}, dtype={dtype}, "
83
  f"pil_size={size}, pil_mode={mode}",