-
Notifications
You must be signed in to change notification settings - Fork 264
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
feat: Add support for iframe based video sampling #590
Conversation
7ea6a76
to
029f34c
Compare
8b2b129
to
0f6d7c5
Compare
eva/parser/eva.lark
Outdated
@@ -122,6 +122,8 @@ subquery_table_source_item: (select_statement | LR_BRACKET select_statement RR_B | |||
|
|||
sample_clause: SAMPLE decimal_literal | |||
|
|||
sample_clause_with_type: SAMPLE decimal_literal string_literal |
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.
We should also support SAMPLE IFRAMES.
I feel this is an important usecase
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.
default the sampling rate to 1
eva/readers/decord_reader.py
Outdated
for frame_id in range(begin, end + 1, self._sampling_rate): | ||
frame = video[frame_id] | ||
if frame is not None: | ||
yield {"id": frame_id, "data": frame} |
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.
Add seconds here
eva/readers/decord_reader.py
Outdated
frame = video[frame_id] | ||
idx += self._sampling_rate | ||
if frame is not None: | ||
yield {"id": frame_id, "data": frame} |
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.
Add seconds here
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.
Also add it in the opencv_reader
test/readers/test_decord_reader.py
Outdated
) | ||
batches = list(video_loader.read()) | ||
for batch in batches: | ||
print(batch) |
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.
Remove this print
test/readers/test_decord_reader.py
Outdated
def tearDown(self): | ||
file_remove("dummy.avi") | ||
|
||
def test_should_sample_every_k_frame(self): |
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.
Also, add a test case for IFrames. Thanks!
eva/readers/decord_reader.py
Outdated
can be converted to ranges. Defaults to None. | ||
sampling_rate (int, optional): Set if the caller wants one frame | ||
every `sampling_rate` number of frames. For example, if `sampling_rate = 10`, it returns every 10th frame. If both `predicate` and `sampling_rate` are specified, `sampling_rate` is given precedence. | ||
sampling_type (str, optional): Set as 'iframe' if caller want to sample on top on iframes only. |
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.
Provide a few simple examples for explainability.
Rest looks good!
7c2685b
to
bd140c3
Compare
Now videos can be sampled for IFRAMES using 'iframe' keyword with SAMPLE clause
e.g.
==> SELECT id FROM MyVideo SAMPLE IFRAMES 7 ORDER BY id;
==> SELECT id FROM MyVideo SAMPLE IFRAMES ; # this uses default sampling rate of 1