You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyTorch maDLC analysis crashes post-inference with ValueError: need at least one array to stack #3108
After training up a PyTorch model, I ran the analysis step in order to extract outlier frames.
The analysis step run to 100% and then threw an error.
100%|██████████|1296914/1296914 [15:18:47<00:00, 23.53it/s]
Traceback (mostrecentcalllast):
File"/home/ts/scripts/DLC_analyze_and_extract.py", line71, in<module>sys.exit(main())
File"/home/ts/scripts/DLC_analyze_and_extract.py", line37, inmaindeeplabcut.analyze_videos(
File"/home/ts/miniforge3/envs/dlc/lib/python3.12/site-packages/deeplabcut/compat.py", line953, inanalyze_videosreturnanalyze_videos(
File"/home/ts/miniforge3/envs/dlc/lib/python3.12/site-packages/deeplabcut/pose_estimation_pytorch/apis/videos.py", line689, inanalyze_videos_generate_assemblies_file(
File"/home/ts/miniforge3/envs/dlc/lib/python3.12/site-packages/deeplabcut/pose_estimation_pytorch/apis/videos.py", line883, in_generate_assemblies_fileunique_bpts=np.stack(keypoint_preds[num_bodyparts:])
File"/home/ts/miniforge3/envs/dlc/lib/python3.12/site-packages/numpy/core/shape_base.py", line445, instackraiseValueError('need at least one array to stack')
ValueError: needatleastonearraytostack
I tried with both autotrack = true and false, tried stitching the tracklets after the analysis.
All resulted in the same error.
Even a short 2 minute clip caused the same error.
With some trial and error I figured out that the _full.pickle file is not written, but the _full.pickle.dat, _full.pickle.dir, _full.pickle.bak, and _meta.pickle exist.
Steps To Reproduce
Train pytorch model
run analysis
see failure once 100% is reached
No _full.pickle
Relevant log output
Anything else?
Tried it both with rc10 and rc12, both with the same error.
Also both dekr_w48 and dlcrnet_stride32_ms5 show the same behavior.
Pytorch is 2.8.0+cu128
I can share a reproducible example via email with a 2 min video.
Thanks for the detailed report and for trying both rc10/rc12 and different backbones — that’s useful context.
The error you’re seeing:
unique_bpts = np.stack(keypoint_preds[num_bodyparts:])
ValueError: need at least one array to stack
means that the slice keypoint_preds[num_bodyparts:] is empty, so there are no arrays to combine. In practice this usually points to an issue with the predicted unique bodyparts: either no detections were produced beyond the number of “individual” bodyparts, or the assembly step doesn’t find anything to stack.
This could happen if:
All detections for some (or all) unique bodyparts are empty,
The number of bodyparts specified in the config doesn’t match what the model was trained to predict,
Or there’s a mismatch between the project configuration and the model configuration.
Could you check if there’s any reason on your side why the model might not be producing predictions for those bodyparts? If not, the best next step would be to share:
Your project’s config.yaml (from the project folder), and
Your model’s pytorch_config.yaml (from the shuffle folder).
That will help us reproduce and see if the mismatch comes from the config or from the analysis pipeline.
from what I can see from the model evaluation, the unique bodyparts are detected decently, and I don't spot a mismatch between the configs.
Here are the two requested files
Thanks for sharing the configs — I also don’t see a mismatch there, so things look consistent on that front.
To move forward, it would be very helpful if you could provide a minimal reproducible example. For instance, a short video (like the 2-minute one you mentioned) along with the corresponding project folder that triggers the error would let us investigate directly. If possible, please share it via Google Drive, WeTransfer, or a similar service, and post the link here (or send it privately if needed).
That way we can try to reproduce the exact error and pinpoint whether it’s coming from the analysis step itself or from the specific data/model combination.
After some reflection, this seems similar to what I reported here #2975 (comment)
The main difference are the other issue was on a Windows system, while this issue is on a Linux HPC.
But both issues are with the same data and config.
The other issue relied on using the GUI, this issue runs headless.
Thank you for your detailed report and for taking the time to trace the issue — feedback like this really helps us improve DeepLabCut! 🙏
I’ve opened a Pull Request (#3112) that fixes the problem you identified. The bug was caused by unique_bodyparts and identity_scores being overwritten with None inside ShelfWriter.add_prediction().
You can already test the fix by installing DeepLabCut from my fix branch, or simply wait for the PR to be merged — the update should be included in the next release shortly.
Activity
maximpavliv commentedon Oct 1, 2025
Hi @tsievert ,
Thanks for the detailed report and for trying both rc10/rc12 and different backbones — that’s useful context.
The error you’re seeing:
means that the slice
keypoint_preds[num_bodyparts:]is empty, so there are no arrays to combine. In practice this usually points to an issue with the predicted unique bodyparts: either no detections were produced beyond the number of “individual” bodyparts, or the assembly step doesn’t find anything to stack.This could happen if:
Could you check if there’s any reason on your side why the model might not be producing predictions for those bodyparts? If not, the best next step would be to share:
config.yaml(from the project folder), andpytorch_config.yaml(from the shuffle folder).That will help us reproduce and see if the mismatch comes from the config or from the analysis pipeline.
tsievert commentedon Oct 1, 2025
Hey @maximpavliv,
from what I can see from the model evaluation, the unique bodyparts are detected decently, and I don't spot a mismatch between the configs.
Here are the two requested files
config.yaml
pytorch_config.yaml
maximpavliv commentedon Oct 1, 2025
Thanks for sharing the configs — I also don’t see a mismatch there, so things look consistent on that front.
To move forward, it would be very helpful if you could provide a minimal reproducible example. For instance, a short video (like the 2-minute one you mentioned) along with the corresponding project folder that triggers the error would let us investigate directly. If possible, please share it via Google Drive, WeTransfer, or a similar service, and post the link here (or send it privately if needed).
That way we can try to reproduce the exact error and pinpoint whether it’s coming from the analysis step itself or from the specific data/model combination.
tsievert commentedon Oct 1, 2025
Could you tell me to which email I could send the link? I'm not aware of a DM function in Github
maximpavliv commentedon Oct 1, 2025
You can send it to my email address: [email protected]
tsievert commentedon Oct 2, 2025
After some reflection, this seems similar to what I reported here #2975 (comment)
The main difference are the other issue was on a Windows system, while this issue is on a Linux HPC.
But both issues are with the same data and config.
The other issue relied on using the GUI, this issue runs headless.
tsievert commentedon Oct 2, 2025
Quick update, the error persists with rc13
maximpavliv commentedon Oct 2, 2025
Thanks for the update @tsievert .
I managed to reproduce the issue with the data you sent me. I will investigate this further next week, I'll keep you posted.
Best,
Maxim
maximpavliv commentedon Oct 6, 2025
Hi @tsievert ,
Thank you for your detailed report and for taking the time to trace the issue — feedback like this really helps us improve DeepLabCut! 🙏
I’ve opened a Pull Request (#3112) that fixes the problem you identified. The bug was caused by
unique_bodypartsandidentity_scoresbeing overwritten withNoneinsideShelfWriter.add_prediction().You can already test the fix by installing DeepLabCut from my fix branch, or simply wait for the PR to be merged — the update should be included in the next release shortly.
Thanks again for helping make DLC better! 🚀
tsievert commentedon Oct 7, 2025
Hey @maximpavliv,
Thank you so much for the fix!
I can confirm that the branch seems to work as intended.