Describe the bug
After training the network (resnet_50), evaluating it and analyzing videos, I get markers that seems to be correctly placed but with wrong labels (they seems to be mixed randomly). This happened after that I added new label names in the config file and (re)labeled previous and new videos.
I tried a number of things:
Indeed I also noticed that the order of the label names (in the column) in the .csv files of each labeled video is not always the same. This is because I added new labels and changed the order of the labels in my config file. Is it possible that deeplabcut get confused by that and use the wrong order for the labels?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Not getting mixed labels ^^
Desktop:
we will look into it, thanks!
quick Q: "Train the network + evaluate" <-- did you reload the previous weights or use "fresh weights"? Just asking to help us debug.
I used fresh weights (I manually deleted the trained networks in the dlc_model folder).
Another thing, I tried removing the folders in labeled-data that had a CollectedData_.csv with the wrong order of label names. That solved the issue of the mixed labels after training and evaluating.
This can indeed, in certain situation be wrong. We have a fix now. Will be released soon.
I tried reordering the label names in the CollectedData_.csv of all labeled videos (with following script), it solved my problem.
import pandas as pd
from glob import glob
import deeplabcut as dlcpath_labels = "path_labeled-data_folder"
path_cfg = "path_config.yaml"path_labels = glob(path_labels + '*')
label_names_commas = 'copy/past 2nd ligne of a correct CollectedData_.csv (should be something like: 'bodyparts,mouth,mouth,tail,tail)'
coord_names_commas = 'copy/past 3nd ligne of a correct CollectedData_.csv (should be something like: coords,x,y,x,y)'
label_names = label_names_commas.split(',')
coord_names = coord_names_commas.split(',')label_keys = pd.MultiIndex.from_tuples(zip(label_names, coord_names))
for p in path_labels:
path_csv = glob(p + '/CollectedData_*.csv') for c in path_csv: header = list(pd.read_csv(c, header=None).loc[0]) df = pd.read_csv(c, header=[1, 2]) df_reorder = df[label_keys] # rearrange column here df_reorder.columns = pd.MultiIndex.from_tuples(zip(header, label_names, coord_names)) df_reorder.to_csv(c, index=False)dlc.convertcsv2h5(path_cfg, userfeedback=False)
That makes sense, in the future this should no longer be necessary with DLC 2.1.8 :)
Just did more testing, while shuffling wildly. Now, I can no longer get such errors!
fixed; pip install deeplabcut==2.1.8
Great!! Thank you very much!