Skip to content

Releases: talmolab/sleap-io

sleap-io v0.2.0

04 Nov 22:53
53c1062
Compare
Choose a tag to compare

What's Changed

  • Update backend filename when backend isn't created on replace by @talmo in #127
  • Update labels videos list on replace by @talmo in #128
  • Add video writing by @talmo in #129
    • Add sio.VideoWriter: basic imageio-ffmpeg video writer with sensible H264 presets. This can be used as a context manager:
      with sio.VideoWriter("video.mp4") as vw:
          for frame in video:
              vw(frame)
    • Add sio.save_video: high-level video writing. This can be used to quickly write a set of frames or even a whole Video for easy (if inefficient) re-encoding:
      bad_video = sio.load_video("unseekable.avi")
      sio.save_video(bad_video, "seekable.mp4")
    • Added IndexError in VideoBackend to enable sequence protocol for iteration over Videos:
      for frame in video:
          pass
    • Refactored sio.io.video to sio.io.video_reading.
  • Fixes to get JABS export to work with new data by @talmo in #132
  • Make skeleton nodes mutable by @talmo in #135
  • Add skeleton manipulation utilities by @talmo in #136
    • Skeleton
      • __contains__(node: NodeOrIndex): Returns True if a node exists in the skeleton.
      • rebuild_cache(): Method allowing explicit regeneration of the caching attributes from the nodes.
      • Caching attributes are now named _name_to_node_cache and _node_to_ind_cache, better reflecting the mapping directionality.
      • require_node(node: NodeOrIndex, add_missing: bool = True): Returns a Node given a Node, int or str. If add_missing is True, the node is added or created, otherwise an IndexError is raised. This is helpful for flexibly converting between node representations with convenient existence handling.
      • add_nodes(list[Node | str]): Convenience method to add a list of nodes.
      • add_edges(edges: list[Edge | tuple[NodeOrIndex, NodeOrIndex]]): Convenience method to add a list of edges.
      • rename_nodes(name_map: dict[NodeOrIndex, str] | list[str]): Method to rename nodes either by specifying a potentially partial mapping from node(s) to new name(s), or a list of new names. Handles updating both the Node.name attributes and the cache.
      • rename_node(old_name: NodeOrIndex, new_name: str): Shorter syntax for renaming a single node.
      • remove_nodes(nodes: list[NodeOrIndex]): Method for removing nodes from the skeleton and updating caches. Does NOT update corresponding instances.
      • remove_node(node: NodeOrIndex): Shorter syntax for removing a single node.
      • reorder_nodes(new_order: list[NodeOrIndex]): Method for setting the order of the nodes within the skeleton with cache updating. Does NOT update corresponding instances.
    • Instance/PredictedInstance
      • update_skeleton(): Updates the points attribute on the instance to reflect changes in the associated skeleton (removed nodes and reordering). This is called internally after updating the skeleton from the Labels level, but also exposed for more complex data manipulation workflows.
      • replace_skeleton(new_skeleton: Skeleton, node_map: dict[NodeOrIndex, NodeOrIndex] | None = None, rev_node_map: dict[NodeOrIndex, NodeOrIndex] | None = None): Method to replace the skeleton on the instance with optional capability to specify a node mapping so that data stored in the points attribute is retained and associated with the right nodes in the new skeleton. Mapping is specified in node_map from old to new nodes and defaults to mapping between node objects with the same name. rev_node_map maps new nodes to old nodes and is used internally when calling from the Labels level as it bypasses validation.
    • Labels
      • instances: Convenience property that returns a generator that loops over all labeled frames and returns all instances. This can be lazily iterated over without having to construct a huge list of all the instances.
      • rename_nodes(name_map: dict[NodeOrIndex, str] | list[str], skeleton: Skeleton | None = None): Method to rename nodes in a specified skeleton within the labels.
      • remove_nodes(nodes: list[NodeOrIndex], skeleton: Skeleton | None = None): Method to remove nodes in a specified skeleton within the labels. This also updates all instances associated with the skeleton, removing point data for the removed nodes.
      • reorder_nodes(new_order: list[NodeOrIndex], skeleton: Skeleton | None = None): Method to reorder nodes in a specified skeleton within the labels. This also updates all instances associated with the skeleton, reordering point data for the nodes.
      • replace_skeleton(new_skeleton: Skeleton, old_skeleton: Skeleton | None = None, node_map: dict[NodeOrIndex, NodeOrIndex] | None = None): Method to replace a skeleton entirely within the labels, updating all instances associated with the old skeleton to use the new skeleton, optionally with node remapping to retain previous point data.
  • Add more checks for video seeking/reading failure by @talmo in #138
  • Fix HDF5Video edge cases by @talmo in #137
  • Docs changelog generation by @talmo in #130
  • Add Labels.extract, Labels.trim and Video.save by @talmo in #140
    • LabeledFrame.frame_idx: Now always converted to int type.
    • Video.close(): Now caches backend metadata to Video.backend_metadata to persist metadata on close.
    • copy.deepcopy() now works on Video objects even if backend is open.
    • Video.save(save_path: str | Path, frame_inds: list[int] | np.ndarray | None = None, video_kwargs: dict[str, Any] | None = None): Method to save a video file to an MP4 using VideoWriter with an optional subset of frames.
    • Labels.extract(inds: list[int] | list[tuple[Video, int]] | np.ndarray, copy: bool = True): Add method to extract a subset of frames from the labels, optionally making a copy, and return a new Labels object.
    • Labels.trim(save_path: str | Path, frame_inds: list[int] | np.ndarray, video: Video | int | None = None, video_kwargs: dict[str, Any] | None = None): Add method to extract a subset of the labels, write a video clip with the extracted friends, and adjust frame indices to match the clip.
  • Docs automation by @talmo in #141
  • Add more examples to docs by @talmo in #142

Full Changelog: v0.1.10...v0.2.0

sleap-io v0.1.10

03 Oct 04:13
8ed557b
Compare
Choose a tag to compare

What's Changed

  • Fix embedded video lookup by @talmo in #122
  • Add better support for exporting and loading RGB videos from .pkg.slp files by @talmo in #125
  • Fix video indexing when embedding from labels that already have embedded data by @talmo in #126

Full Changelog: v0.1.9...v0.1.10

sleap-io v0.1.9

29 Sep 02:14
bbee932
Compare
Choose a tag to compare

What's Changed

  • Dependency management by @talmo in #118
    • Drop av as a dependency since it's still a little buggy and doesn't have broad enough platform compatibility.
    • Pin ndx-pose < 0.2.0 until #104 is merged in.
    • Remove livecov dev tool as it was interfering with VSCode debugging.
  • Safer video loading from SLP by @talmo in #119
    • Added sio.io.utils.is_file_accessible to check for readability by actually reading a byte. This catches permission and other esoteric filesystem errors (addresses #116).
    • Explicit control over whether video files should be opened when loading labels with:sio.load_slp(..., open_videos=False)
    • Explicit control over whether backend is auto-initialized when creating or using Video objects with Video(..., open_backend=False).
    • More sanitization of filenames to posix/forward-slash safe forms when reading and writing SLP files.
  • Fix split calculation and allow for not embedding by @talmo in #120
    • Fix: The function now correctly splits the labels into training, validation, and test sets based on the specified proportions (fixes #117). Previously, the validation fraction was being computed incorrectly in cases where its relative fraction was 1.0 after taking out the train split.
    • Enhancement: Labels.make_training_splits(..., embed=False). Previously, the function would always embed the images, which could be slow for large projects. With this change, the embed parameter is introduced, allowing the user to choose whether to embed the images or save the labels with references to the source video files.

Full Changelog: v0.1.8...v0.1.9

sleap-io v0.1.8

11 Sep 22:51
096eefd
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.1.7...v0.1.8

sleap-io v0.1.7

02 Aug 01:40
e002927
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.1.6...v0.1.7

sleap-io v0.1.6

16 Jul 01:55
5b79a22
Compare
Choose a tag to compare

What's Changed

  • Grayscale property passthrough by @talmo in #99

Full Changelog: v0.1.5...v0.1.6

sleap-io v0.1.5

19 Jun 14:05
5a30110
Compare
Choose a tag to compare

What's Changed

  • Labels.split and Labels.make_training_splits by @talmo in #98

Full Changelog: v0.1.4...v0.1.5

sleap-io v0.1.4

05 Jun 11:21
d857684
Compare
Choose a tag to compare

What's Changed

  • Add support for embedding images in .pkg.slp by @talmo in #91
    • Saving SLP files with embedded images will re-save the embedded images.
    • Embed images into SLP files with:
      • labels.save("labels.pkg.slp", embed="user") to embed frames with user-labeled instances (Instance)
      • labels.save("labels.pkg.slp", embed="user+suggestion") to embed frames with user-labeled instances and suggestion frames (useful for inference after training)
      • labels.save("labels.pkg.slp", embed="source") to restore the source video ("unembed")
  • Better reprs and QOL by @talmo in #96
    • Better __repr__s for Skeleton, LabeledFrame, Labels, Instance, PredictedInstance
    • Labels.append() and Labels.extend() to add LabeledFrames now will update Labels.tracks, Labels.skeletons and Labels.videos with contents.
    • Labels.update() to manually update Labels.tracks, Labels.skeletons and Labels.videos with contents of Labels.labeled_frames and Labels.suggestions.
    • Labels.replace_filenames(): multiple methods for replacing all video filenames across the project (#85).
    • Skeleton.edge_names to return list of edges as tuples of string names
    • Added docstrings to sio.load_video and related high level Video APIs to clarify supported file formats.
    • Syntactic sugar: try to initialize video backend with Video(filename) construction (#94)

Note: This is a re-release of v0.1.3 which had a borked deployment.

Full Changelog: v0.1.2...v0.1.4

sleap-io v0.1.3

05 Jun 11:17
cd96be4
Compare
Choose a tag to compare

What's Changed

  • Add support for embedding images in .pkg.slp by @talmo in #91
    • Saving SLP files with embedded images will re-save the embedded images.
    • Embed images into SLP files with:
      • labels.save("labels.pkg.slp", embed="user") to embed frames with user-labeled instances (Instance)
      • labels.save("labels.pkg.slp", embed="user+suggestion") to embed frames with user-labeled instances and suggestion frames (useful for inference after training)
      • labels.save("labels.pkg.slp", embed="source") to restore the source video ("unembed")
  • Better reprs and QOL by @talmo in #96
    • Better __repr__s for Skeleton, LabeledFrame, Labels, Instance, PredictedInstance
    • Labels.append() and Labels.extend() to add LabeledFrames now will update Labels.tracks, Labels.skeletons and Labels.videos with contents.
    • Labels.update() to manually update Labels.tracks, Labels.skeletons and Labels.videos with contents of Labels.labeled_frames and Labels.suggestions.
    • Labels.replace_filenames(): multiple methods for replacing all video filenames across the project (#85).
    • Skeleton.edge_names to return list of edges as tuples of string names
    • Added docstrings to sio.load_video and related high level Video APIs to clarify supported file formats.
    • Syntactic sugar: try to initialize video backend with Video(filename) construction (#94)

Full Changelog: v0.1.2...v0.1.3

sleap-io v0.1.2

22 May 15:59
4af9f38
Compare
Choose a tag to compare

What's Changed

  • Fix suggestions deserialization by @talmo in #95

Full Changelog: v0.1.1...v0.1.2