MCPcopy Create free account
hub / github.com/EmbodiedGPT/EmbodiedGPT_Pytorch / load_video

Function load_video

demo/inference.py:145–169  ·  view source on GitHub ↗
(video_path, num_segments=8)

Source from the content-addressed store, hash-verified

143 return image
144
145def load_video(video_path, num_segments=8):
146 vr = VideoReader(video_path, ctx=cpu(0))
147 num_frames = len(vr)
148 frame_indices = get_index(num_frames, num_segments)
149
150 # transform
151 crop_size = 224
152 scale_size = 224
153 input_mean = [0.48145466, 0.4578275, 0.40821073]
154 input_std = [0.26862954, 0.26130258, 0.27577711]
155
156 transform = T.Compose([
157 GroupScale(int(scale_size), interpolation=InterpolationMode.BICUBIC),
158 GroupCenterCrop(crop_size),
159 Stack(),
160 ToTorchFormatTensor(),
161 GroupNormalize(input_mean, input_std)
162 ])
163
164 images_group = list()
165 for frame_index in frame_indices:
166 img = Image.fromarray(vr[frame_index].asnumpy())
167 images_group.append(img)
168 video = transform(images_group)
169 return video
170
171class StoppingCriteriaSub(StoppingCriteria):
172

Callers 2

generate_streamFunction · 0.70
get_video_embeddingMethod · 0.70

Calls 6

get_indexFunction · 0.90
GroupScaleClass · 0.90
GroupCenterCropClass · 0.90
StackClass · 0.90
ToTorchFormatTensorClass · 0.90
GroupNormalizeClass · 0.90

Tested by

no test coverage detected