Label video when num_outputs > 1 (and overwriting flag) #2096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi DLC team!
Based on a reply of @MMathisLab on an unrelated PR, I went ahead and added
num_outputs: 2in theconfig.yamlfile of a model trained from frames/videos of a single animal, but which I wanted to use to analyze videos containing two animals. Callinganalyze_videoworked 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, callingcreate_labeled_videoresulted 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_videothat 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