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

Function load_video

demo/script.py:208–232  ·  view source on GitHub ↗
(video_path, num_segments=8)

Source from the content-addressed store, hash-verified

206 return image
207
208def load_video(video_path, num_segments=8):
209 vr = VideoReader(video_path, ctx=cpu(0))
210 num_frames = len(vr)
211 frame_indices = get_index(num_frames, num_segments)
212
213 # transform
214 crop_size = 224
215 scale_size = 224
216 input_mean = [0.48145466, 0.4578275, 0.40821073]
217 input_std = [0.26862954, 0.26130258, 0.27577711]
218
219 transform = T.Compose([
220 GroupScale(int(scale_size), interpolation=InterpolationMode.BICUBIC),
221 GroupCenterCrop(crop_size),
222 Stack(),
223 ToTorchFormatTensor(),
224 GroupNormalize(input_mean, input_std)
225 ])
226
227 images_group = list()
228 for frame_index in frame_indices:
229 img = Image.fromarray(vr[frame_index].asnumpy())
230 images_group.append(img)
231 video = transform(images_group)
232 return video
233
234class StoppingCriteriaSub(StoppingCriteria):
235

Callers 1

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