megvii-research / CADDM

Official implementation of ID-unaware Deepfake Detection Model
Apache License 2.0
146 stars 21 forks source link

File paths not resolving correctly in extract_frames_ldm_ff++.py #13

Closed angelaragonkifute closed 1 year ago

angelaragonkifute commented 1 year ago

In extract_frames_ldm_ff++.py the default parameter for the variable NUM_FRAMES is 1. In this case there is no problem, in terms of corresponding frames, if only one frame is taken from each video, for a given fake video, its frame 0 will correspond perfectly with its source video frame 0. The problem comes when NUM_FRAMES is not 1. Let's consider NUM_FRAMES = 30. In this case, according to this code the frame index that will be taken will follow a linear distribution so if there are 300 frames and 30 frame are desired, frames 0,10,20,...,290,300 are taken. This is a problem since source videos and fake videos don't always have the same length so ifi 30 frames are desired for video fake A, frames 0,10,20,30,...300 are taken but if video source B has, for example 270 frames, then frames 0,9,18,27,37...270 will be taken. It is a small detail and to some extent is not even a problem because the frames will be very similar but the source paths are not entirely accurate.

Leesoon1984 commented 1 year ago

Same Problem, have you solved it?

angelaragonkifute commented 1 year ago

@Leesoon1984 Basically changed this line: https://github.com/megvii-research/CADDM/blob/82ac7bfc82215ee243d536da695b0f194c0d6317/lib/extract_frames_ldm_ff%2B%2B.py#L76 with something like frame_idxs = np.arange(0,NUM_FRAMES+1,FRAMES_STEP), so you will always take for instance 0,10,20,...,300 in the case NUM_FRAMES=300 and FRAMES_STEP=10 if a video doesn't have enough frames, it will raise a controlled error and continue.