-
Notifications
You must be signed in to change notification settings - Fork 97
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
Loading new skeleton from file causes labels to contain multiple conflicting skeletons #713
Comments
Hi @e-velin, I was able to replicate the error above - thanks for providing such detail. This seems like a bug on our part - i.e. not updating the skeleton in the Project 1: Edit and Save Skeleton in GUI
Project 2: New Project with Saved Skeleton
|
Hi @e-velin, No code-based fix yet, but an update as to why the problem may be occurring. I found that if I follow the steps above, but refrain from loading a new skeleton into the project (namely Project 1 steps 4-6), then I get no error messages. It seems the error is occurring because there is more than one skeleton in a single project. In the case that the skeletons are different in the two projects, then I get the following warning upon "Merge into Project": but, the merge still completes successfully. Thus, it does not matter if the skeletons in the two projects are different (as the skeletons will be merged), but it does matter if a single project has more than one skeleton - see the error in previous comment. I will keep you updated, |
Hi @roomrys, I am getting the same error as above. In my case is happening when I try to add to my main project a `predictions.slp' file. What I am try to do is to merge into my main project the prediction.slp file generated by using sleap-track, to be able to expand my dataset. Could somebody help with this issue? Thanks |
Hi @cosimogonnelli, Can you try the above, but skip the manual loading of the skeleton. The preditions.slp and your main project will both already have skeletons which SLEAP will merge together when selecting the "Merge Into Project...". To be explicit, can you
Do not try to load in the skeleton beforehand. Please let us know if that helps. Thanks, |
Hi @roomrys, Thanks for your help! I still have the same issue. Please let me know what I should try next to move forward. This is what I tried: 1 - File > Open Project > labels.v002.slp This is the code I used to generate the predictions |
Hi @cosimogonnelli, Based on your results, either Open IPython
In IPython CLI
In [1]: import sleap
In [2]: labels = sleap.Labels.load_file("D:\\the-path-to-your-slp\\labels.v001.slp")
In [3]: labels.skeletons
Out[3]: [Skeleton(name='Skeleton-0', nodes=['mouth', 'l_mouth', 'l_head', 'r_mouth', 'r_head'], edges=[('mouth', 'l_mouth'), ('mouth', 'l_head'), ('mouth', 'r_mouth'), ('mouth', 'r_head')], symmetries=[])]
In [4]: len(labels.skeletons)
Out[4]: 1
The Let us know if you need help and also please update with your findings. Thanks, |
Hi @roomrys, So it turned out that I have 5 skeleton in my main project and 1 in the predictions.slp file. How did I managed to do that and how do I delete the extra skeletons? This is very useful staff to know thanks! |
Hi @cosimogonnelli, Ok, so we will first check which skeleton is used - hopefully only one skeleton is used (otherwise we have another bug on our hand that roots from #713). In IPython CLI (after loading the labels)
In [5]: skeletons_used = list(set([inst.skeleton for lf in labels.labeled_frames for inst in lf.instances]))
In [6]: skeletons_used
Out[6]: [Skeleton(name='Skeleton-0', nodes=['head', 'f_dorsal', 'r_dorsal'], edges=[('f_dorsal', 'head'), ('f_dorsal', 'r_dorsal')], symmetries=[])]
In [7]: assert len(skeletons_used) == 1
In [8]: labels.skeletons = skeletons_used
In [9]: labels.save("D:\\path-to-save-your-slp\\new_slp.slp") Let us know how that goes. Thanks, |
Hi @roomrys, I suppose I have to import some module since I get the error: Thanks for helping with this! |
Hi @cosimogonnelli, Oof, my bad - I switched the ordering of the nested
Thanks, |
Hi @roomrys, Thanks for your help! it definitely helps to understand how SLEAP works. So The code you provided seems working correctly. Do you have any idea why I ended up with 5 skeletons? I am sure I created only one. Not totally sure but I might have had to modify it. If this is the case it might happen that anytime I made a change a new skeleton get created.. |
Hi @cosimogonnelli, We have only seen this bug occur if the user elects to Load Skeleton when a project already has a skeleton. The Load Skeleton appends the skeleton to a list of skeletons (laying the ground work for supporting multi-skeleton projects - not yet a feature). However, much of our code asserts that the project should only have one skeleton loaded to ensure things work as expected (until we add support for multi-skeleton projects). Editing the skeleton does not append a new skeleton to the Thanks, |
Hi @roomrys , I encountered this same problem when trying to merge a new project .slp with labels into my main project .slp, even when I open my main project .slp without loading the skeleton first. I checked the number and identity of skeletons using the code you provided above. It turns out that my main project has two skeletons, which have the same nodes and edges but with a slightly different edge order (see below). My main project uses one version of this skeleton, whereas the new project uses the other version of this skeleton (again, with otherwise identical nodes and identical edges).
Additionally, I have some questions about merging practices. In order for labels in the source file (i.e. new project .slp) to be merged into the destination file (i.e. main project .slp), does the destination file already need to have the video added? As an alternative to merging, is there a way to copy and paste instances from one file to another? Many, many thanks, |
Hi @shwan19, Thanks for reporting! Did you happen to use The video does not need to be added prior to merging (it will be added during the merge). The merging takes care of merging skeletons whereas copy-pasting would recreate the multiple skeleton issue. Is there a specific goal you would like to accomplish with copy-paste style merging? Thanks, |
Hi @roomrys , I appreciate your quick response! Yes, I'm certain that I used Load Skeleton at some point in the project, as I had tested multiple skeletons before settling on the current one. I only ask about copy-pasting because I have a not-huge number of instance labels I'm trying to merge. But if there's a more robust way to merge, I would gladly do that instead of copy-pasting. Do you recommend a specific work-around for merging (or its equivalent) given the multiple skeletons issue? (In my case, it's really the same skeleton, just the edge order is different between the two variants...) Thanks again, |
Hi @shwan19, Ok thanks for clarifying - The merging should work after these steps:
Let us know if you are having any trouble. Thanks, |
Hello, I was having a similar issue with multiple skeletons and followed the instructions above. However, we seem to be having an issue saving the corrected label file, as indicated below.
Thank you for your assistance! |
Since multiple skeletons are used in the project (referenced by instances), you will need to set each instance to reference the last remaining skeleton before saving the project. labels.skeleton = skeletons_used[-1]
for instance in labels.instances():
instance.skeleton = labels.skeleton Hope this helps! Let us know if you are still having trouble. Thanks, P.S. #913 deals with a similar issue. |
Hi, I'm having problems with merging different sleap projects again. I have a main project with multiple labeled videos, I trained the network on this dataset. Based on your previous suggestions here, I checked in ipython and this slp file uses one skeleton. I have multiple smaller slp project files with 10 videos, where I predicted the pose based on the training on the main project and the predictions were hand corrected. Now when I'm trying to merge these projects with the main project, I receive this error: |
Hi @e-velin, Thank you for your detailed background above. Do you mind providing me a few numbered steps to try and replicate (starting after you have the trained model, i.e. how are you running inference GUI -> local, GUI -> export -> Colab, CLI). Also, for troubleshooting purposes, which SLEAP version are you on and how did you install (source, conda package, or pip)? Thanks for your help! |
Hi @roomrys, I also tried finding a workaround by exporting the corrected annotations from the smaller projects to h5 files and importing them into the main project, with adding the corresponding videos to the main project, then I get |
Hi @e-velin, QuestionDid you run inference remotely and then have to merge in the predictions? We have our suspicions that the merging code might be causing duplicate skeletons. TracingIf this is a problem from just running inference (no merging), then... SLEAP determines which skeleton to use when running inference by looking at the config Line 1533 in d05e2bf
However, when we create a Trainer.from_config , we overwrite the config skeletons with the skeletons in the training labelsLine 677 in d05e2bf
Well, we use the index 0 to determine which skeleton to use here... is it possible that we use another index elsewhere to determine which skeleton? Yes, there is this suspect lineLines 1480 to 1481 in d05e2bf
from a commit titled Update the GUI skeleton after inference if it changed (#414) - also very suspicious. So if merging is adding multiple skeletons, we choose to use the last skeleton in our GUI, but then use the first skeleton for adding predictions. Another workaround#913 provides a workaround for the multiple duplicate skeletons:
Help with your workaroundSLEAP expects sleap/sleap/info/write_tracking_h5.py Line 86 in d05e2bf
sleap/sleap/info/write_tracking_h5.py Lines 120 to 122 in d05e2bf
but I wonder if the last two dimensions might be flipped, (x,y) and track_count . We can check the dimensions of the tracks_matrix via the analysis notebook (renamed locations ).
Thanks, |
Hi @roomrys, Answer to your questionThanks for inspecting my problem. No, I didn't run inference remotely, but on my computer. So I have a big "merged" slp file, I trained the network on these annotations. I created multiple smaller slp files with 10 videos only (because at some point I had trouble opening slp files with more videos but I can solve that now by running "ulimit -n 2000" in command line after activating the sleap conda environment and before opening the gui). Then I opened these smaller slp files on the same computer, made inference immediately (without loading in a specific skeleton file first) with the network trained on the bigger slp file then I sent the smaller slp files to a different computer where they were corrected (sleap v 1.2.9, Mac pro intel) and now I'm trying to merge them into the bigger slp file and I receive this error message. Feedback on the other workaroundI tried Talmo's suggestion and actually all the corrected annotations disappeared. They are present in the Instances menu but with 0/14 Points (so no body parts appear on the frames). Feedback on help with my workaroundThe shape of one of the videos' "locations" variable (based on the analysis notebook) from one of my smaller slp files is: (129, 14, 2, 1), if this is what you referred to. So "2" (x,y coordinates' number) and track_count is not flipped. |
Hi,
I'm trying to merge two sleap projects. In both of the projects I used the same skeleton but in the first project initially I annotated the head as well, later I decided I don't need that and deleted it. Now I can see that the skeleton file still contains the head but on the annotated frames they are not visible. When I'm trying to merge the two projects, I get the error message 'ValueError: Labels.skeleton can only be used when there is only a single skeleton saved in the labels. Use Labels.skeletons instead.' So I tried to load in into the first project a clean skeleton json file without that does not contain the head (the skeleton file that I saved from the second project). The skeleton number doesn't change in the GUI to the number of the loaded skeleton, but if I save the skeleton file into a new json file, the new, loaded skeleton number will appear. Yet, I get the same error message when I try to merge the two projects. However, when I close the first project and reopen it, it still contains the old skeleton file with the head node, even when I save the skeleton into a json file. Can you help with this please? This happens both is v1.1.5 and v1.2.2.
Similar to this: #592
The text was updated successfully, but these errors were encountered: