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

Syntactic sugar: sio.Video(filename) #94

Closed
talmo opened this issue May 21, 2024 · 0 comments · Fixed by #96
Closed

Syntactic sugar: sio.Video(filename) #94

talmo opened this issue May 21, 2024 · 0 comments · Fixed by #96

Comments

@talmo
Copy link
Contributor

talmo commented May 21, 2024

Right now, creating a video with sio.Video(filename) will not initialize the backend, which might lead to weird downstream errors like:

NotImplementedError: Cannot serialize video backend for video: Video(filename="/home/jovyan/talmolab-smb/datasets/mot/animal/sleap/SLAP_M74/four_mice/val/top-10072022151549-0000_h265_CRF12_denoised.mp4", shape=None, backend=NoneType)

We could handle backend initialization (like in sio.Video.from_filename constructor) in the post init similarly to how we handle the sio.Labels(lfs) syntax here:

def __attrs_post_init__(self):
"""Append videos, skeletons, and tracks seen in `labeled_frames` to `Labels`."""
for lf in self.labeled_frames:
if lf.video not in self.videos:
self.videos.append(lf.video)
for inst in lf:
if inst.skeleton not in self.skeletons:
self.skeletons.append(inst.skeleton)
if inst.track is not None and inst.track not in self.tracks:
self.tracks.append(inst.track)

It might also be good to refactor both of these into an instance method in case we want to do these manually.

@talmo talmo linked a pull request Jun 5, 2024 that will close this issue
@talmo talmo closed this as completed in #96 Jun 5, 2024
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 a pull request may close this issue.

1 participant