Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off-by-one issues with the frame sampling #22

Open
bryant1410 opened this issue Jul 30, 2021 · 0 comments
Open

Off-by-one issues with the frame sampling #22

bryant1410 opened this issue Jul 30, 2021 · 0 comments

Comments

@bryant1410
Copy link
Contributor

bryant1410 commented Jul 30, 2021

I think there may be 2 off-by-one issues with the frame sampling. I'm not so sure about it and prefer to discuss it, that's why I don't send a patch.

For the first one, this is the part of the code:

intervals = np.linspace(start=0, stop=vlen, num=acc_samples + 1).astype(int)
ranges = []
for idx, interv in enumerate(intervals[:-1]):
ranges.append((interv, intervals[idx + 1] - 1))

I think it should be:

np.linspace(start=0, stop=vlen - 1, ...)

(with a - 1)

and:

ranges.append((interv, intervals[idx + 1]))

(without the - 1).

Otherwise, the right part of each bucket it's gonna be ignored. For the uniform case, instead of doing the interval centroid ((a+b)/2), it takes (a+b-1)/2. This isn't a big deal though.

For the second one, I think the random choice interval end should be + 1. When it does random.choice(range(...)) (which btw could be a random.randrange), the range excludes the stop value, so there's another - 1 hidden there.

For example, in the training video "1013731484", which has only one frame according to Decord, for random it'd be:

intervals == [0, 1]
ranges = [(0, 0)]
random.choice(range(0, 0)) == random.choice([]) <- exception

And it fails silently, assigning all frames to black. Note this one also isn't a big deal as it'd fail with few videos, and with the rest, it'd have all the intervals shifted or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant