From ea46ebca5ee9c4edf0b7c7d44de069d4241a03d5 Mon Sep 17 00:00:00 2001 From: generatedunixname1401739305002972 Date: Wed, 6 May 2026 02:08:24 -0700 Subject: [PATCH] Fix PYRE_MISSING_ANNOTATIONS issues in fbcode/deeplearning/projects/sam3_release/sam3/model/io_utils.py Differential Revision: D103516284 fbshipit-source-id: 8fd9ffd8abd1dd59a4ccad9c1be39f8d7e1d01cd --- sam3/model/io_utils.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sam3/model/io_utils.py b/sam3/model/io_utils.py index 02a2146..a2cdde4 100644 --- a/sam3/model/io_utils.py +++ b/sam3/model/io_utils.py @@ -361,7 +361,9 @@ def load_dummy_video(image_size, offload_video_to_cpu, num_frames=60, do_zeros=F return images, video_height, video_width -def _load_img_as_tensor(img_path, image_size): +def _load_img_as_tensor( + img_path: str, image_size: int +) -> tuple[torch.Tensor, int, int]: """Load and resize an image and convert it into a PyTorch tensor.""" img = Image.open(img_path).convert("RGB") orig_width, orig_height = img.width, img.height @@ -532,15 +534,15 @@ class AsyncVideoFileLoaderWithTorchCodec: def __init__( self, - video_path, - image_size, - offload_video_to_cpu, - img_mean, - img_std, - gpu_acceleration=True, - gpu_device=None, - use_rand_seek_in_loading=False, - ): + video_path: str, + image_size: int, + offload_video_to_cpu: bool, + img_mean: Union[tuple[float, float, float], torch.Tensor], + img_std: Union[tuple[float, float, float], torch.Tensor], + gpu_acceleration: bool = True, + gpu_device: Optional[torch.device] = None, + use_rand_seek_in_loading: bool = False, + ) -> None: # Check and possibly infer the output device (and also get its GPU id when applicable) assert gpu_device is None or gpu_device.type == "cuda" gpu_id = (