Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
=======================================
Coverage 93.99% 93.99%
=======================================
Files 5 5
Lines 416 416
=======================================
Hits 391 391
Misses 25 25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks @lochhh! Happy to review this one. |
niksirbi
left a comment
There was a problem hiding this comment.
Thanks @lochhh. This brings as closer to being able to make a higher-level conversion API, akin to #50, but we should probably tackle #58 before we attempt that.
I've left some notes, but most of them are ideas for improvement that could be also done as follow-up. Do them in this PR or open them as issues, as you prefer.
The only issue that needs fixing is in the crash on grayscale videos (see inline comment).
I'm pre-approving this for your convenience.
| # - Labeled frames are not stored as image files; they are read directly | ||
| # from the videos referenced by the labels file. |
There was a problem hiding this comment.
It is worth qualifying this statement a bit? That's true of 'standard' .slp files, but in .pkg.slp files the frames can be stored inside the file itself.
I wonder if at some point we need a helper in poseinterface.io that can take frames from a variety of sources (extracted from the video, taken from .pkg.slp, or directly as an image sequece) and write them in PoseMark format. That would also replcae the inline imegeio loop later in this example.
Not needed for this PR, but sth to keep in mind.
There was a problem hiding this comment.
| # Extract this session's user annotations (dropping any predicted | ||
| # instances), save them to a temporary per-session labels file, and | ||
| # convert them to COCO frame labels JSON. | ||
| session_labels = labels.extract(source_video_path) | ||
| session_labels.remove_predictions() | ||
| with tempfile.TemporaryDirectory() as tmp_dir: | ||
| session_labels_path = Path(tmp_dir) / f"{source_video_path.stem}.slp" | ||
| session_labels.save(session_labels_path) | ||
| framelabels_path = annotations_to_posemark( | ||
| input_path=session_labels_path, | ||
| output_dir=target_frames_dir, | ||
| format="frame", | ||
| **ids, | ||
| ) |
There was a problem hiding this comment.
Each session's labels here have to take a detour through a temporary .slp file because annotations_to_posemark only accepts a file path.
I wonder if it's possible to have it also accept a labels object loaded with sleap-io. That would remove the need for this detour.
Could be also explored in a follow-up PR.
| / "sleap" | ||
| / "MouseTopDown-EPM" | ||
| ) | ||
| print(tree(source_project_dir, level=1, exclude_hidden=True)) |
There was a problem hiding this comment.
Use level=2 to also show the predictions file names?
| print(tree(source_project_dir, level=1, exclude_hidden=True)) | |
| print(tree(source_project_dir, level=2, exclude_hidden=True)) |
There was a problem hiding this comment.
the 2 other examples use level=1 - should all of these use 2?
Co-authored-by: Niko Sirmpilatze <niko.sirbiladze@gmail.com>
Description
What is this PR
Why is this PR needed?
Closes #83
Adds SLEAP project → PoseMark example, so we now cover DLC, LP, and SLEAP.
What does this PR do?
This PR
tests/data/sleap/MouseTopDown-EPM. The.slpfiles are created synthetically, based on MouseTopDown-Loukia-2022-09-13 - verified by loading the .slp files in the SLEAP GUI. The difference here is that the SLEAP labels file uses frame numbers 10, 50, 90 because the videos only have 100 frames, rather than those that are way out of the videos; the DLC data uses frame numbers >100. I've avoided naming the SLEAP data the same as for DLC for this reason. Perhaps a future PR to clean up the test fixtures, e.g. A more cohesive set of test fixtures #53 could consider unifying the datasets across different tools - this would also be useful for round-trip tests, for instance, making sure that converting the same datasets in different format results in the same PoseMark dataset..lp_sessionfiles in a separate temp dir instead of storing them in the posemark base dir (for cleaner separation - in case the script crashes and never reaches the clean-up step, these session files will stay in the base dir).References
#83
How has this PR been tested?
Docs built locally
Does this PR require an update to the documentation?
This is a documentation update
Checklist: