MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / _load_img_v2_as_tensor

Function _load_img_v2_as_tensor

tools/preprocess/sam_utils.py:18–27  ·  view source on GitHub ↗
(img, image_size)

Source from the content-addressed store, hash-verified

16
17
18def _load_img_v2_as_tensor(img, image_size):
19 img_pil = Image.fromarray(img.astype(np.uint8))
20 img_np = np.array(img_pil.convert("RGB").resize((image_size, image_size)))
21 if img_np.dtype == np.uint8: # np.uint8 is expected for JPEG images
22 img_np = img_np / 255.0
23 else:
24 raise RuntimeError(f"Unknown image dtype: {img_np.dtype}")
25 img = torch.from_numpy(img_np).permute(2, 0, 1)
26 video_width, video_height = img_pil.size # the original video size
27 return img, video_height, video_width
28
29
30def load_video_frames(

Callers 1

load_video_frames_v2Function · 0.85

Calls 2

convertMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected