-
Notifications
You must be signed in to change notification settings - Fork 114
Add video models + functions #814
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #814 +/- ##
==========================================
+ Coverage 87.74% 87.81% +0.07%
==========================================
Files 129 130 +1
Lines 11462 11633 +171
Branches 1545 1567 +22
==========================================
+ Hits 10057 10216 +159
- Misses 1017 1023 +6
- Partials 388 394 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Amazing PR!
It would be great to use concise and minimalistic naming and API because we are going to have many file types for multiple domains.
- Naming
Keywords like Meta will make it hard for user to remember and use the classes - user have their own meta 🙂
How about this renaming:
VideoFile -> BaseVideo (I assume people won't use this often)
VideoMeta -> Video (the most used class)
VideoClip -> Clip (also, shouldn't it be based on Video with meta?)
VideoFrame -> FrameBase
VideoFrameMeta -> Frame
start_time --> start
end_time --> end
frames_count --> count
Image -> BaseImage
ImageMeta -> Image
FileTypes can be also extended: image
(read meta), base_image
(do not read meta), video
(read meta), base_video
(do not read meta), video_clip
, base_video_clip
, ...
- Do we need dummy classes?
I assume that people prefer working with meta information while dealing with images and videos. A followup question - do we really need BaseImages
and BaseVideo
without any logic? Why don't we clean up API and keep only Meta-enrich version in the API? User still can work with videos as File if meta is not needed.
- Do we need singular methods?
save_video_clips()
and save_video_clip()
How much extra code user needs to get rid of singular form. If one method - let's avoid the singular version.
The same question for video_frames()
and video_frames_np()
I assume, we can add the method and classes later if there is a need. But I'd not start with such rich API for now and try my best to keep in minimalistic.
WDYT?
Deploying datachain-documentation with
|
Latest commit: |
4098e8b
|
Status: | ✅ Deploy successful! |
Preview URL: | https://4d43370e.datachain-documentation.pages.dev |
Branch Preview URL: | https://video-models.datachain-documentation.pages.dev |
for more information, see https://pre-commit.ci
👍
For now we have naming with
Done. Only
We don't have
That's good suggestion, only we use
Good question. I've added def video_meta(file: "VideoFile") -> Video:
"""
Returns video file meta information.
Args:
file (VideoFile): VideoFile object.
Returns:
Video: Video file meta information.
"""
Sounds reasonable to me 👍 Will update the code (not done yet).
Done.
Those are great comments! Love the discussion ❤️ |
|
||
def save(self, destination: str): | ||
"""Writes it's content to destination""" | ||
self.read().save(destination) | ||
|
||
|
||
class Image(DataModel): |
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.
why do we need this separate model?
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.
Same as for video info (Video
model). I can remove it from this PR 🤔
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.
it's just a bit weird that we have ImageFile and Image (that contains only some basic metadata) 🤔
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.
It was VideoMeta
(and ImageMeta
) before, but Dmitry was asked to rename these models here. I agree having Video
(Image
) model with just meta looks odd. I think you're right and we should inherit this model from VideoFile
(ImageFile
) to extend files with meta, than it will make sense. If no, what do you think about VideoInfo
(and ImageInfo
)?
src/datachain/lib/file.py
Outdated
|
||
return video_frame(self, frame, format) | ||
|
||
def save_frame(self, frame: int, output_file: str) -> "VideoFrame": |
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.
does VideoFrame has information that is needed it to be File?
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.
Good question. VideoFrame
class looks like this:
class VideoFrame(VideoFile):
"""`DataModel` for reading video frames."""
frame: int = Field(default=-1)
timestamp: float = Field(default=-1.0)
orig: File
It is inherited from VideoFile
, which is inherited from File
. I am thinking now this VideoFrame
model should be inherited from ImageFile
instead, because it is an image.
Also I am not sure TBH if we need orig: File
here (also should it be orig: VideoFile
?)
Also what if we want to have "virtual video frame" model? Inherited from VideoFile, so we do have a video file in this model and with additional frame
and timestamp
fields. This way we can do not store frame in the storage and use original video file and strip the frame from it then needed.
Many questions regarding to the API, many answers but same time it is way to much for this PR and we need real world use cases and examples to make it all works the best way.
It is now 👍 |
src/datachain/lib/file.py
Outdated
codec: str = Field(default="") | ||
|
||
|
||
class Frame(DataModel): |
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.
I would suggest to rename those back to SomethingMeta if we keep this approach
it is super confusing - VideoFrame and Frame - which one is the main class?
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.
cc @dmpetrov
for more information, see https://pre-commit.ci
In this Video Models PR, we now have models for:
There are some questions about this implementation:
|
Continue work in #890 |
See #797
Video models added
Meta models added
Usage examples
Can be found here: iterative/datachain-examples#28