MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / read_frames_folder

Function read_frames_folder

data/video_utils.py:99–115  ·  view source on GitHub ↗
(video_path, num_frames, sample='rand', fix_start=None, min_num_frames=4)

Source from the content-addressed store, hash-verified

97
98
99def read_frames_folder(video_path, num_frames, sample='rand', fix_start=None, min_num_frames=4):
100 image_list = sort_frames(list(os.listdir(video_path)))
101 frames = []
102 for image in image_list:
103 fp = os.path.join(video_path, image)
104 frame = Image.open(fp).convert('RGB')
105 frames.append(frame)
106 vlen = len(frames)
107
108 t_num_frames = np.random.randint(min_num_frames, num_frames + 1)
109
110 if vlen > t_num_frames:
111 frame_indices = get_frame_indices(
112 t_num_frames, vlen, sample=sample, fix_start=fix_start
113 )
114 frames = [frames[i] for i in frame_indices]
115 return frames
116
117
118class FrameSampler:

Callers

nothing calls this directly

Calls 4

sort_framesFunction · 0.85
get_frame_indicesFunction · 0.85
openMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected