Oryx-mllm / Oryx

MLLM for On-Demand Spatial-Temporal Understanding at Arbitrary Resolution
https://oryx-mllm.github.io
291 stars 14 forks source link

Question about inference.py #15

Closed VOXXXX1874 closed 1 month ago

VOXXXX1874 commented 1 month ago

In line 116-119 of inference.py , the frames are uniformly sampled from the video

uniform_sampled_frames = np.linspace(0, total_frame_num - 1, args.frames_upbound, dtype=int)
frame_idx = uniform_sampled_frames.tolist()
spare_frames = vr.get_batch(frame_idx).asnumpy()
video = [Image.fromarray(frame) for frame in spare_frames]

Suppose I have a 20sec 30fps video and I set the frames_upbound as 64, it will sample following frames

[0, 9, 19, 28, 38, 47, 57, 66, 76, 85, 95, 104, 114, 123, 133, 142, 152, 161, 171, 180, 190, 199, 209, 218, 228, 237, 247, 256, 266, 275, 285, 294, 304, 313, 323, 332, 342, 351, 361, 370, 380, 389, 399, 408, 418, 427, 437, 446, 456, 465, 475, 484, 494, 503, 513, 522, 532, 541, 551, 560, 570, 579, 589, 599]

After that, in line 137-145 of inference.py, when the frames are preprocessed, only the frames with enumerated idx in the frame_idx will be appended to the video

for idx, frame in enumerate(video):
        image_processor.do_resize = False
        image_processor.do_center_crop = False
        frame = process_anyres_video_genli(frame, image_processor)

        if frame_idx is not None and idx in frame_idx:
            video_processed.append(frame.unsqueeze(0))
        elif frame_idx is None:
            video_processed.append(frame.unsqueeze(0))

The enumerated idx will be

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]

Therefore, only the following idx will be choosen

[0, 9, 19, 28, 38, 47, 57]

It means only the frames sampled from the first two seconds is choosen. It seems unreasonable. I wonder whether it is a mistake or it is designed like that?

dongyh20 commented 1 month ago

Thanks for pointing this out! We have updated our code to fix this issue