Label video when num_outputs > 1 (and overwriting flag) by ludovicbellier · Pull Request #2096 · DeepLabCut/DeepLabCut
Hi DLC team!
Based on a reply of @MMathisLab on an unrelated PR, I went ahead and added num_outputs: 2 in the config.yaml file of a model trained from frames/videos of a single animal, but which I wanted to use to analyze videos containing two animals. Calling analyze_video worked fine, and the resulting HDF file contained for each body part two sets of x,y,likelihood (namely, 'x', 'y', 'likelihood', 'x2', 'y2', 'likelihood2'). However, calling create_labeled_video resulted in an indexing error ("IndexError: index N is out of bounds for axis 0 with size N", N being the number of body parts), and it came from the fact that while I had 2N sets of estimates (two per body part), there were only N colors (one per body part; further details in the code).
This PR fixes the bug described above by taking into account situations where num_outputs>1 in single animal models, in a parsimonious approach (i.e., by replacing existing lines of code so that output using num_outputs=1 doesn't change at all, and output using num_outputs>1 is now valid, as opposed to adding a new situation).
Also, while doing this debugging I constantly had to manually delete the created movie, so I implemented an overwriting flag in create_labeled_video that defaults at False. Turning it to True forces overwriting.
(besides, here's the bottom line of my attempt at estimating poses for the two animals: while the video did show two labels per body part after debugging, on many frames my animal of interest had two labels on it for the same body part, so it looks like a dead end for this strategy in my use case, and I'll have to rely on masking!)
Please don't hesitate if you need further information!
Best,
Ludovic