MCPcopy Create free account
hub / github.com/MStypulkowski/diffused-heads / get_id_frame

Function get_id_frame

utils.py:50–63  ·  view source on GitHub ↗
(path, random=False, resize=128)

Source from the content-addressed store, hash-verified

48
49
50def get_id_frame(path, random=False, resize=128):
51 if path.endswith('.mp4'):
52 vr = decord.VideoReader(path)
53 if random:
54 idx = [np.random.randint(len(vr))]
55 else:
56 idx = [0]
57 frame = vr.get_batch(idx).permute(0, 3, 1, 2)
58 else:
59 frame = load_image_to_torch(path).unsqueeze(0)
60
61 frame = (frame / 255) * 2 - 1
62 frame = Resize((resize, resize), antialias=True)(frame).float()
63 return frame
64
65
66def get_motion_transforms(args):

Callers 1

mainFunction · 0.90

Calls 1

load_image_to_torchFunction · 0.85

Tested by

no test coverage detected