Skip to content

Add video example #28

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add video example #28

wants to merge 7 commits into from

Conversation

dreadatour
Copy link
Contributor

@dreadatour dreadatour commented Jan 20, 2025

Video example for iterative/datachain#890

Note: This PR is also required: iterative/datachain#900

@dreadatour dreadatour self-assigned this Jan 20, 2025
@dreadatour dreadatour marked this pull request as draft January 20, 2025 19:10
@dreadatour dreadatour marked this pull request as ready for review January 27, 2025 18:24
Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we work with a local storage there? it should cloud

@shcheklein
Copy link
Member

shcheklein commented Jan 28, 2025

map(lambda file: file.get_info(), output={'meta': Video})

can it be w/o output - it looks heavy for such a basic task. Can it be a single model - File + Meta (not sure how to organize it better tbh)

annotations_dc = DataChain.from_csv( )

can we avoid creating a data model explicitly? from_csv should be able to figure out the schema and create Pydantic model for us

file_stem = file.get_file_stem()

file_ext = file.get_file_ext()
file_name = f"{file_stem}_{timestamp}.jpg"
file_path = f"data/ava/frames/{file_name}"
frame = file.save_frame(round(timestamp * meta.fps), file_path)

should be part of some helper ... ideally for saving a frame we don't have to do UDFs

@dreadatour
Copy link
Contributor Author

Updated example to work with cloud (including upload).
Simplify it a lot, it is now only:

  • getting video meta
  • saving video fragments
  • saving video frames

@dreadatour
Copy link
Contributor Author

can it be w/o output - it looks heavy for such a basic task. Can it be a single model - File + Meta (not sure how to organize it better tbh)

Done, fixed. The reason why it wasn't working before is because of typings in function definition.

Before:

if TYPE_CHECKING:
    from datachain.lib.file import Video, VideoFile

def video_info(file: "VideoFile") -> "Video":

After:

from datachain.lib.file import Video, VideoFile

def video_info(file: VideoFile) -> Video:

@dreadatour
Copy link
Contributor Author

can we avoid creating a data model explicitly? from_csv should be able to figure out the schema and create Pydantic model for us

We can not in this case, because this CSV file does not have headers :(
I can not update this file manually because I am downloading it from URL.

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

Successfully merging this pull request may close these issues.

3 participants