Fix SAM3 io_utils to handle extensionless video files from OIL

Summary: Fix SAM3 io_utils.py to handle extensionless video files from OIL (Object Image Library). Previously, the code would immediately raise NotImplementedError when encountering files without recognized video extensions. This change attempts to load such files as videos using the video loader, only raising an exception if the actual decoding fails. This enables SAM3 to process OIL-stored video paths that don't include file extensions.

Differential Revision: D99228861

fbshipit-source-id: c93d089ad4b7eac9e0eb629d7a71b021604db410
This commit is contained in:
Minh Vu
2026-04-12 02:38:44 -07:00
committed by meta-codesync[bot]
parent bfbed072a0
commit 44ef224799
2 changed files with 126 additions and 1 deletions
+17 -1
View File
@@ -159,7 +159,23 @@ def load_video_frames(
video_loader_type=video_loader_type,
)
else:
raise NotImplementedError("Only video files and image folders are supported")
# No recognized extension (e.g., extensionless OIL paths) — attempt video loading.
# Only raise if the loader itself fails to decode frames.
try:
return load_video_frames_from_video_file(
video_path=video_path,
image_size=image_size,
offload_video_to_cpu=offload_video_to_cpu,
img_mean=img_mean,
img_std=img_std,
async_loading_frames=async_loading_frames,
video_loader_type=video_loader_type,
)
except Exception as e:
raise NotImplementedError(
f"Only video files and image folders are supported; "
f"failed to load '{video_path}' as video: {e}"
) from e
def load_video_frames_from_image_folder(