-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Adding Random Seed for Frame Processing #3416
Adding Random Seed for Frame Processing #3416
Conversation
be44674
to
acb4007
Compare
28ba7d7
to
aff0083
Compare
aff0083
to
489fb68
Compare
random.seed(random_seed) | ||
frame_indices = sorted(random.sample(range(num_frames), num_frames_target)) | ||
select_cmd = "select='" + "+".join([f"eq(n\,{idx})" for idx in frame_indices]) + "',setpts=N/TB," | ||
CONSOLE.print(f"Extracting {num_frames_target} frames using seed-based random selection.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could u also print the random_seed here as well?
frame_indices = sorted(random.sample(range(num_frames), num_frames_target)) | ||
select_cmd = "select='" + "+".join([f"eq(n\,{idx})" for idx in frame_indices]) + "',setpts=N/TB," | ||
CONSOLE.print(f"Extracting {num_frames_target} frames using seed-based random selection.") | ||
elif spacing > 1: | ||
CONSOLE.print("Number of frames to extract:", math.ceil(num_frames / spacing)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also make the print log more clear that the extracted frame is evenly spacing?
@@ -41,6 +41,10 @@ class VideoToNerfstudioDataset(ColmapConverterToNerfstudioDataset): | |||
"""Feature matching method to use. Vocab tree is recommended for a balance of speed | |||
and accuracy. Exhaustive is slower but more accurate. Sequential is faster but | |||
should only be used for videos.""" | |||
random_seed: Optional[int] = None | |||
"""Random seed to select video frames""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this random seed for select training set? maybe make it more clear in the comments
This PR relates to the Issue #3048
Background: Currently, frame processing video logic works by sampling N frames from N evenly spaced intervals throughout the video. Although a worthy method, researchers should be allowed to choose frames from a random seed to produce more consistent results.
This PR implements optional --random_seed and --eval_random_seed flags for the ns-process-data video in case a specific seed is requested.
Verification Evidence: Placed a video and a random seed to produce a consistent result
Here is the result
Unit Tests: A function to test_misc that confirms that the random_seed processes the number of frames correctly.
Future Work: After this alternative, finding ways to choose frames based on blurriness and other forms of visual change is necessary. Create an integration test with ns-process-data video since there is only one for image currently.