Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Bug description
Hello. First of all, thank you so much for your help. I'm a DLC beginner, so I apologize if this is not a bug but a issue with my labelling.
I am trying to train my model with videos of birds. I have 244 images and 13 for testing. Because the bird keeps moving, some points disappear which is why I've tried to label with a total of 5 labels. (except for a few seconds, at least one label is visible) This might be a source of error but I've seen people say that labels will automatically disappear when the parts aren't
visible.
I trained my model for 200 epochs when training loss was 0.0000 and validation loss was 0.0002. But when I try to analyze/make labelled videos, the video does not show ANY labels and skeletons. The trajectory plot somehow shows that except for some, most labels have gone to the top left corner (Though the Plot likelihood is high.)
The csv file shows that some tracking is happening. The spreadsheet graph below is what I get when I graph the y-coordinates show in the csv file. Still, some points remain near the axis.
How can I make sure that my video is tracking accurately?
Operating System
MacOS Sonoma 14.3
DeepLabCut version
dlc version 3.0.0rc6
(Terminal said "zsh: command not found: import" when using import deeplabcut. 3.0.0rc6 is what terminal says when GUI is opening)
DeepLabCut mode
single animal
Device type
cpu (mac)
Steps To Reproduce
I am using deeplabcut for pytorch with a gui. My yaml file has 5 body parts and my label was done according to this.
Relevant log output
#final model performance
Epoch 200/200 (lr=1e-06), train loss 0.00000, valid loss 0.00002
Model performance:
metrics/test.rmse: 261.97
metrics/test.rmse_pcutoff: 351.65
metrics/test.mAP: 7.74
metrics/test.mAR: 12.31
metrics/test.rmse_detections: 268.90
metrics/test.rmse_detections_pcutoff: 364.06Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct



Activity
n-poulsen commentedon Jan 29, 2025
Hi @ottersum! From the metrics, your model performance looks quite bad (RMSE is pixel error), but the loss indicates the model is well trained.
I spotted a really weird issue with the
MPSdevice and PyTorch on OSX two days ago, which was fixed in #2849. Could you try:pytorch_config.yamlfile for your model so that you have"device: cpu", and then runevaluate_network again? The metrics should be much betterpip install --upgrade "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc"in your conda environment to have the latest version of the code and evaluate again?ottersum commentedon Jan 29, 2025
@n-poulsen Thank you for your suggestions. I tried applying them below.
INFO:console:train rmse 246.27train rmse_pcutoff 383.50train mAP 12.10train mAR 17.59test rmse 269.04test rmse_pcutoff 364.52test mAP 8.84test mAR 11.54pip install --upgrade "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc"but it said something like the url was invalid so I didpip install --upgrade deeplabcut. Terminal said a bunch ofRequirement already satisfied. And when I did the evaulation again, it was the same as above.Below are the plot-poses for another video when I tried analyzing it once I did steps 1 and 2. This time all 4 plots were empty and I couldn't see the labels in the video. Still, the csv file (image below) does show some numbers.
[EDIT] I tried to plot 2 of the tracked x and y values on through spreadsheet. These points seem okay (except for some that are clustered around the origin), but this is not shown on any plots/videos.
Since I didn't re-train the model (I just re-evaluated it), I will update again after my training is done (it seems to take a while). Also, you mentioned that my rmse was bad but the training loss/valid loss was good. Is there a reason why this might be?
Thank you for your help!!
n-poulsen commentedon Jan 29, 2025
@ottersum I believe the loss is very low but the RMSE is high because of the bug I resolved in #2849 (for short - there's a bug in PyTorch where when copying data from an 'MPS' tensor to a 'CPU' tensor only part of the data is copied - which would explain why some of your keypoints are always predicted at 0). You shouldn't need to re-train your model if this was the bug, as the issue was only there for evaluation.
Could you let me know the full error that's printed when running
pip install --upgrade "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc"in your conda environment? I just tried this on my end and didn't get any issues.
As two next steps, could you please:
check_labels(in the GUI, it's in the Label frames tab) and check that there are no errors in your annotations (here are the docs for this function)? Really check that the"left"`"right"` labels are correct as that's a common source of error and can really lead to the model being confused.evaluate_networkwith "Plot predictions" selected - and look at what your model predictions look like compared to your ground truth data (documentation for this is here)ottersum commentedon Jan 29, 2025
Thank you for your reply!
I actually tried the
pip install --upgrade "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc"again but this time it installed something and worked. (I apologize, but I already deleted the terminal window with the error so I couldn't copy it here.)When I checked the labels, I found a total of 6 label order errors. Thank you for pointing this out. I have fixed all labeling for the videos that contained the errors. I didn't train my network according to the fixed labels yet. Please let me know if I should re-train my model and evaluate the new network.
Despite running the
pip upgrade, I've noticed that the problem persisted.When I tried evaluating the network, somehow it didn't work now. The progress bars were full as shown below but it was taking forever to load and didn't give me any data in the end. Is this possibly because I fixed the labels and now I'm testing for a old model with a new set?
100%|█████████████████████████████████████████| 244/244 [09:29<00:00, 2.34s/it]100%|███████████████████████████████████████████| 13/13 [00:06<00:00, 2.06it/s]As for video analyzing, I've attached a copy of the plot pose that was created from the original model with your pip update code. The video made from 'create videos' still does not have any labels as well.
Thank you so much for your help.
n-poulsen commentedon Jan 30, 2025
Thanks @ottersum - now I would start by re-training the network with the fixed labels. To make sure evaluation happens smoothly, you can delete the current evaluation results.
Let me know if your issue is fixed after this!
ottersum commentedon Jan 30, 2025
@n-poulsen
Thank you for your response.
I've started to re-train my model with the correctly labeled images but noticed after the first 10 epoches that the rmse was still very high.
Is this normal for the first 10 epochs or is there still an issue with my DLC or training?
n-poulsen commentedon Jan 30, 2025
The loss is very low compared to the metrics that are being output (with a loss so low, you would expect the model to be almost perfect) - and if the loss is too small, then the model might won't be able to learn anything.
Would you be willing to share a few of the images you labeled (the ones output by "check labels") so I can take a look and see if I spot anything wrong?
ottersum commentedon Jan 30, 2025
@n-poulsen
These are some images that I see when I see check labels. I've also attached a picture I took from the DLC folder of 'labeled-data'. I've labeled a total of 5 parts (left eye, left nostril, between the beak, right nostril and the right eye.) As you can see, not are labels are visible in every frame (I believe most frames have 4 with some even having none when the bird turns around).
Referring to what you said about the loss being low, do you know why this would this be? When I trained for 200 epochs, the training loss was actually 0.0000 at the end. Do you think this might be the problem?
Because these videos aren't actually not mine, I am a bit hesitant about leaving it up. Would you mind if I delete them once you respond?
Thank you so much for your help.
n-poulsen commentedon Jan 30, 2025
@ottersum no problem deleting the images - your data looks well labeled. How large are the images (their resolution in pixels)?
Yes I believe that's a symptom for the issue - could you share your project's
config.yamland thepytorch_config.yamlfor the model you trained?There's no issues with some keypoints not being visible in images, the model learns not to output those keypoints.
ottersum commentedon Jan 30, 2025
@n-poulsen Thank you. My images are the pixel of my images are 832 × 724 (from dimensions once I clicked 'get info' on the images). As for the yaml files, I've copied them below.
(Edit): While I was copying this, I noticed that I added youre
device:cpusuggestion to the project yaml instead of the pytorch yaml file. I've added it now. I apologize for the oversight.Project yaml
pytorch yaml
[edit]: Just in case it helps, this is the latest evaluation for the model I am trying to train with newly labeled images.
Thank you so much. Please let me know if you need any more information!
n-poulsen commentedon Jan 30, 2025
@ottersum no worries! the
devicekey is actually already present a bit higher up in thepytorch_config.yamlfor your model (seedevice: auto) - could you edit it there as well so you have:And try running "evaluate network" again (delete the content of the evaluation-results-pytorch folder first, so we're sure the results are fresh)?
ottersum commentedon Jan 30, 2025
@n-poulsen Thank you so much for the quick reply!
I've changed
device:autointodevice:cpuin the pytorch yaml file. I'm actually training the new model right now so I can't evaluate it just yet. I edited my previous message to include an update with the training which I've copied below.I've deleted the old evaluation results file in my DLC folder during training too. Would it be okay if I update you with 'evaluate network' results once my training is complete?
n-poulsen commentedon Jan 30, 2025
@ottersum that would be good - could you also run the "extract_save_all_maps" function? You need to do this through code though (it isn't available in the GUI yet - you can open a shell by calling
ipythonin your terminal):Then if you can share the maps that are produced in the
evaluate_networkfolder?n-poulsen commentedon Jan 30, 2025
@ottersum ah sorry - this isn't a big issue; just need to run
evaluate_networkfirst (and no worries about deleting messages):ottersum commentedon Jan 30, 2025
@n-poulsen Thank you for your understanding!
The new set with the evaluate network seemed to work perfectly. Once I completed
deeplabcut.evaluate_network(config, Shuffles=[1], device="cpu")I got a new set of evaluations that seem to be different from what I have been getting.n-poulsen commentedon Jan 30, 2025
Awesome your model results look great!! With the results you have I think you can easily start analyzing videos; performance looks very good.
I'll close the issue as I think your problem is resolved, but don't hesitate to re-open it if you run into other issues!
ottersum commentedon Jan 30, 2025
@n-poulsen I hope you don't mind me asking 2 additional questions...
device:cpuin following projects?)Thank you so much for your help!
[-]Error Plotting / Making Videos[/-][+]Error Plotting/Making Videos on MPS - all predictions 0[/+]n-poulsen commentedon Jan 30, 2025
Of course!
You can then try analyzing videos with your trained model and
device: autoagain, and the results should be basically the same as withdevice: cpu. If that's not the case, you can re-open this issue and I can help!ottersum commentedon Jan 31, 2025
Thank you for your reply!
I will try to update DLC later when I need it for another project. I've afraid it might stop working if I update it now...
As for the new model that has finished training today, I've attached a picture of the new plots that work perfectly. The labelled videos look good as well.
Thank you so much for all your help!!
Add a hardware gate for running object detectors on Apple MPS
Add a hardware gate for running object detectors on Apple MPS