Closed catubc closed 3 years ago
Hmm that's odd. Do you mind sharing your DLC CSV file with the labels?
Sure, I put a csv example here:
https://drive.google.com/file/d/1_s5G30roJPd5V6KBrX0mJRTzIB6503EN/view?usp=sharing
And the .h5 file here:
https://drive.google.com/file/d/1R6fKdtEmUOcND4NnaP4SpNH0wp8Wwzji/view?usp=sharing
Note: there are many instances of animals where a feature is occluded, not sure if that's what the issue is.
So I'm able to load the CSV file both in the GUI and interactively:
import sleap
labels = sleap.Labels.load_file("CollectedData_danlab.csv", as_format="deeplabcut")
print(labels.skeleton.node_names)
print(labels[29].instances[0].numpy())
print(labels[29].instances[1].numpy())
Output:
['nose', 'leftear', 'rightear', 'spine1', 'spine2', 'spine3', 'spine4', 'spine5', 'tail1', 'tail2', 'tail3']
[[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[335.57568828 770.96751239]
[304.51417728 787.11949811]
[273.03851279 807.41301863]
[254.40160619 832.26222744]
[ nan nan]
[ nan nan]
[ nan nan]]
[[ nan nan]
[287.53388459 677.78297937]
[276.35174063 721.26909478]
[303.68587032 709.67279733]
[278.83666151 702.63218817]
[248.60345747 710.5011043 ]
[224.16840214 730.79462482]
[206.3598025 755.64383362]
[ nan nan]
[ nan nan]
[ nan nan]]
Let's troubleshoot. Can you try:
which sleap-label
to check that the binary got linked correctly when you upgraded versionsOk, so my workstation SLEAP install broke now, it gives the tensorRT error and I can't seem to be able to fix it. [EDIT: Fixed workstation now...]
But I ran your code on my laptop, here's the output:
(sleap_env) cat@cat-GF63-Thin-9SCX:~$ python
Python 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 23:10:56)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sleap
2020-12-08 15:22:25.190340: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6
2020-12-08 15:22:25.191377: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer_plugin.so.6
>>> labels = sleap.Labels.load_file("/home/cat/Downloads/CollectedData_danlab.csv", as_format="deeplabcut")
>>> print(labels.skeleton.node_names)
['nose', 'leftear', 'rightear', 'spine1', 'spine2', 'spine3', 'spine4', 'spine5', 'tail1', 'tail2', 'tail3']
>>> print(labels.skeleton.node_names)
['nose', 'leftear', 'rightear', 'spine1', 'spine2', 'spine3', 'spine4', 'spine5', 'tail1', 'tail2', 'tail3']
>>> print(labels[29].instances[0].numpy())
[[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[335.57568828 770.96751239]
[304.51417728 787.11949811]
[273.03851279 807.41301863]
[254.40160619 832.26222744]
[ nan nan]
[ nan nan]
[ nan nan]]
>>> print(labels[29].instances[1].numpy())
[[ nan nan]
[287.53388459 677.78297937]
[276.35174063 721.26909478]
[303.68587032 709.67279733]
[278.83666151 702.63218817]
[248.60345747 710.5011043 ]
[224.16840214 730.79462482]
[206.3598025 755.64383362]
[ nan nan]
[ nan nan]
[ nan nan]]
>>> sleap.__version__
'1.0.10a9'
>>>
I can confirm the same output on my workstation (where all the DLC data is hosted).
Let me know any other suggestions.
Ok, and you definitely can't load it in the GUI?
Let's try saving the SLP file interactively in Python:
import sleap
labels = sleap.Labels.load_file("CollectedData_danlab.csv", as_format="deeplabcut")
labels.save("CollectedData_danlab.slp")
And then in the terminal, open the resulting file: sleap-label "CollectedData_danlab.slp"
It's working on my end, but I don't have the images to visualize the labels with.
Let me know what you get and if you see any new errors.
Also here's the converted project file if you want to just try loading the one I created using the snippet above:
Ok
So the save and the reload definitely worked. So something must be goign on with the GUI version.
Let me know if anything else I can test.
Also, it seems the GPU is not working if I want to train on this data. I will open a separate issue. [EDIT: I fixed GPU training now]
Hmm, not sure what could be going on. Here's me importing your data from the GUI using just a black image as a placeholder:
(Click to zoom)
Works now for me as well (with images!). Thanks.
But:
How do I import several .csv files from several movies to train at the same time?
Right, so that's not currently supported but I'm tracking that feature over in issue #412.
Does it work for you if you go to File -> Merge into project... and merge in the separate SLP files converted from each CSV?
Do you have many CSV files such that that would be impractical?
I have 20-30 such files in general. I don't mind doing it.
However, I just tried
Importing DLC .csv <- worked ok
Merging into it from .h5 file (there is no option to merge from .csv), got this crash:
(sleap_env) cat@cat-GF63-Thin-9SCX:~$ sleap-label
2020-12-08 17:10:49.324944: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6
2020-12-08 17:10:49.325993: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer_plugin.so.6
/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/shiboken2/files.dir/shibokensupport/signature/parser.py:97: FutureWarning: split() requires a non-empty pattern match.
return [x.strip() for x in split(argstr) if x.strip() not in ("", ",")]
/home/cat/Downloads/sleap2/CollectedData_danlab.h5 doesn't match ext for json or json.zip
Traceback (most recent call last):
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/gui/commands.py", line 499, in importPredictions
self.execute(MergeProject)
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/gui/commands.py", line 232, in execute
command().execute(context=self, params=kwargs)
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/gui/commands.py", line 125, in execute
self.ask_and_do(context, params)
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/gui/commands.py", line 1854, in ask_and_do
new_labels = Labels.load_file(filename, video_search=gui_video_callback)
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/io/dataset.py", line 1561, in load_file
filename, for_object="labels", video_search=video_search, *args, **kwargs
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/io/format/main.py", line 109, in read
return disp.read(filename, *args, **kwargs)
File "/home/cat/anaconda3/envs/sleap_env/lib/python3.6/site-packages/sleap/io/format/dispatch.py", line 58, in read
raise TypeError("No file format adaptor could read this file.")
TypeError: No file format adaptor could read this file.
Sorry, I wasn't super clear about the procedure. For each CSV file:
Then, open one of the resulting .slp files and now merge them in one-by-one through File -> Merge into project.
I'll tag this as an enhancement so we can streamline the process in a new version :)
As a workaround for now so you can save yourself some clicking for the first step:
import sleap
csv_files = ["path/to/vid1.csv", "path/to/vid2.csv"]
for csv_file in csv_files:
labels = sleap.Labels.load_file(csv_file, as_format="deeplabcut")
labels.save(csv_file + ".slp")
Thanks so much, I will go ahead and do this asap.
Before I do that, I'd like to evaluate SLEAP on a video. So I have now finished training 50 epochs of center and center_instance and would like to label some videos.
I couldn't find a way to do this, did I miss something?
Thanks so much
[EDIT: I see there is some information here as well, I will try to follow this guide:
Just as a piece of future reference until we implement this functionality natively, here's how you can import and merge a set of DLC folders:
import sleap
from glob import glob
csv_files = glob("labeled-data/*/*.csv")
merged_labels = None
for csv_file in csv_files:
labels = sleap.Labels.load_file(csv_file, as_format="deeplabcut")
if merged_labels is None:
merged_labels = labels
else:
merged_labels.extend_from(labels, unify=True)
print("Merged labels:")
merged_labels.describe()
merged_labels.save("merged_labels.slp")
merged_labels.save("merged_labels.pkg.slp", with_images=True) # comment this out to skip saving with embedded images
This assumes a folder structure like this:
labeled-data/
video1/
my_labels.csv
img00000.png
img00001.png
...
video2/
...
I was just running into this issue myself in the latest version and found a work around that isn't mentioned in the thread. I noticed the below error message, particularly "nodes=[M, U, L, T, I, !],"
Instance(skeleton=skeleton, points=instance_points) File "<attrs generated init sleap.instance.Instance>", line 10, in __init__ File "C:\Users\mq20197886\.conda\envs\sleap\lib\site-packages\sleap\instance.py", line 420, in _validate_all_points f"There is no node named {node_name} in {self.skeleton}" KeyError: 'There is no node named HeadBack in Skeleton(nodes=[M, U, L, T, I, !], edges=[], symmetries=[])'
I also noticed that in the multi animal config.yaml in my case and in the user above's case this phrase "bodyparts: MULTI!"
multianimalbodyparts:
- HeadBack
- PincerMid
- LeftEye
- RightEye
- PostPetiole
- ThoraxFront bodyparts: MULTI!
My work around was simply to copy my multianimalbodyparts into bodyparts replacing MULTI!
This appears to solve the issue and my import of the config.yaml appears to be loading everything correctly.
I feel this could be solved on the side of the sleap importer by checking if the DLC project is multi animal, or if there is a multianimalbodyparts field and checking there is bodyparts only contains MULTI!
I am yet to test what effect overwriting bodyparts has on the original DLC project.
Cheers, Trev
Hi I am getting KeyError: 1204 while trying to upload training data of DLC as a .csv file. i am using 1.3.3 version. Its a multi animal project in DLC with 18 joints each.
Hi I installed the prerelast 1.0.10a9
But I still get an error when importing DLC labeled data:
For completeness, here's most of config.yaml file also: