Function save_frame_data_imgstore does not store frames in chronological order. #2097
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
This is a pretty low level function that probably won't work the way you expect it to. In general, the So what are you trying to do exactly? Do you need the images? Let us know and we'll go from there :) Cheers, Talmo |
Beta Was this translation helpful? Give feedback.
-
Hey, sorry for the lack of clearness. I am trying to get the images corresponding only to labeled frames, for each video. I used save_frame_data_imgstore since I preferred to automatize things in a script, but that is not essential. Maybe it is possible to do that by exporting a package via the 'Predict' button in the GUI and going through it in Python? Thank you for the quick answer. *I just realized this might be a duplicate of 1976 and related to 1979 |
Beta Was this translation helpful? Give feedback.
-
Yes, you can Predict > Export Labels Package in the GUI to save out a .pkg.slp which will have images stored in an HDF5 dataset. If you wanted to do this programmatically, SLEAP uses the Lines 2315 to 2399 in 59e1f70 . Even more low-level, the Labels.save_frame_data_hdf5 calls Video.to_hdf5 which shows how the underlying hdf5 dataset is created:Lines 1399 to 1493 in 59e1f70 . The frame indices of the images will match the frame index associated with the list of labeled frames to save images for: Lines 2363 to 2367 in 59e1f70 (this list is sorted by order added/labeled, not by frame index). Let us know if that is helpful or if you are looking for something else - maybe providing a snippet of code with comments for what you were hoping to accomplish? Thanks, |
Beta Was this translation helpful? Give feedback.
-
You can also do something like: import sleap
labels = sleap.load_file("labels.v001.slp")
labels.save("labels.v001.pkg.slp", with_images=True) This will embed the images from your frames into the SLP file and is a bit more convenient than the lower level APIs. Again, depending on what you're trying to do @FranciscoAzevedo, there might be other or more convenient ways to export the data. For example, if you're trying to train models in a different framework, here's an example of converting to Ultralytics format. |
Beta Was this translation helpful? Give feedback.
Hi @FranciscoAzevedo,
Yes, you can Predict > Export Labels Package in the GUI to save out a .pkg.slp which will have images stored in an HDF5 dataset.
If you wanted to do this programmatically, SLEAP uses the
Labels.save_frame_data_hdf5
method to output a list ofVideos
withHDF5Video
backend:sleap/sleap/io/dataset.py
Lines 2315 to 2399 in 59e1f70