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
TypeError: can't assign a numpy.float32 to a torch.FloatTensor #3512
GeForce RTX 4070 Ti; cuda version 13.2, driver 595.84; 13th Gen Intel(R) Core(TM) i9-13900K
Bug description 🐛
DLC hits corrupted frames (unavoidable across 600,000 videos with our hardware), attempts to assign NaN. pytorch catches it / it violates strict type checking.
Fix:
/deeplabcut/pose_estimation_pytorch/models/predictors/paf_predictor.py
line 199: poses[i, j, :, 4] = assembly.affinity.item()
added .item(), extracts item directly. pose prediction then functions as expected.
Steps To Reproduce
load video with corrupted frame --> it'll end up a NaN during deeplabcut.analyze_videos pass.
Relevant log output
lost it when i fixed the bug (see above, fix is in description)
Correction to the fix, apparently. The NaN gets pushed downstream
File ~/miniconda3/envs/finchesPy/lib/python3.12/site-packages/deeplabcut/utils/make_labeled_video.py:1309, in create_video_with_all_detections(config, videos, videotype, shuffle, trainingsetindex, displayedbodyparts, cropping, destfolder, modelprefix, confidence_to_alpha, plot_bboxes, **kwargs)
1307 print("Creating labeled video for ", video_name)
1308 h5file = full_pickle.replace("_full.pickle", ".h5")
-> 1309 data, metadata = auxfun_multianimal.LoadFullMultiAnimalData(h5file)
1310 data = dict(
1311 data
1312 ) # Cast to dict (making a copy) so items can safely be popped
1314 x1, y1 = 0, 0
File ~/miniconda3/envs/finchesPy/lib/python3.12/site-packages/deeplabcut/utils/auxfun_multianimal.py:221, in LoadFullMultiAnimalData(dataname)
219 data = pickle.load(handle)
220 except (pickle.UnpicklingError, FileNotFoundError):
--> 221 data = shelve.open(data_file, flag="r")
222 with open(data_file.replace("_full.", "_meta."), "rb") as handle:
223 metadata = pickle.load(handle)
File ~/miniconda3/envs/finchesPy/lib/python3.12/shelve.py:243, in open(filename, flag, protocol, writeback)
230 def open(filename, flag='c', protocol=None, writeback=False):
231 """Open a persistent dictionary for reading and writing.
232
233 The filename parameter is the base filename for the underlying
(...) 240 See the module's doc string for an overview of the interface.
241 """
--> 243 return DbfilenameShelf(filename, flag, protocol, writeback)
File ~/miniconda3/envs/finchesPy/lib/python3.12/dbm/init.py:85, in open(file, flag, mode)
83 mod = _defaultmod
84 else:
---> 85 raise error[0]("db file doesn't exist; "
86 "use 'c' or 'n' flag to create a new db")
87 elif result == "":
88 # db type cannot be determined
89 raise error[0]("db type could not be determined")
error: db file doesn't exist; use 'c' or 'n' flag to create a new db
Activity
anthonyattacks commentedon Sep 13, 2026
Correction to the fix, apparently. The NaN gets pushed downstream
File ~/miniconda3/envs/finchesPy/lib/python3.12/site-packages/deeplabcut/utils/make_labeled_video.py:1309, in create_video_with_all_detections(config, videos, videotype, shuffle, trainingsetindex, displayedbodyparts, cropping, destfolder, modelprefix, confidence_to_alpha, plot_bboxes, **kwargs)
1307 print("Creating labeled video for ", video_name)
1308 h5file = full_pickle.replace("_full.pickle", ".h5")
-> 1309 data, metadata = auxfun_multianimal.LoadFullMultiAnimalData(h5file)
1310 data = dict(
1311 data
1312 ) # Cast to dict (making a copy) so items can safely be popped
1314 x1, y1 = 0, 0
File ~/miniconda3/envs/finchesPy/lib/python3.12/site-packages/deeplabcut/utils/auxfun_multianimal.py:221, in LoadFullMultiAnimalData(dataname)
219 data = pickle.load(handle)
220 except (pickle.UnpicklingError, FileNotFoundError):
--> 221 data = shelve.open(data_file, flag="r")
222 with open(data_file.replace("_full.", "_meta."), "rb") as handle:
223 metadata = pickle.load(handle)
File ~/miniconda3/envs/finchesPy/lib/python3.12/shelve.py:243, in open(filename, flag, protocol, writeback)
230 def open(filename, flag='c', protocol=None, writeback=False):
231 """Open a persistent dictionary for reading and writing.
232
233 The filename parameter is the base filename for the underlying
(...) 240 See the module's doc string for an overview of the interface.
241 """
--> 243 return DbfilenameShelf(filename, flag, protocol, writeback)
File ~/miniconda3/envs/finchesPy/lib/python3.12/shelve.py:227, in DbfilenameShelf.init(self, filename, flag, protocol, writeback)
225 def init(self, filename, flag='c', protocol=None, writeback=False):
226 import dbm
--> 227 Shelf.init(self, dbm.open(filename, flag), protocol, writeback)
File ~/miniconda3/envs/finchesPy/lib/python3.12/dbm/init.py:85, in open(file, flag, mode)
83 mod = _defaultmod
84 else:
---> 85 raise error[0]("db file doesn't exist; "
86 "use 'c' or 'n' flag to create a new db")
87 elif result == "":
88 # db type cannot be determined
89 raise error[0]("db type could not be determined")
error: db file doesn't exist; use 'c' or 'n' flag to create a new db
proposed solution: edit /deeplabcut/pose_estimation_pytorch/data/postprocessor.py;
on line 542, between the for loop and the heatmap_indices variable, insert to cast nans to 0.0
-----can fully confirm, with the above two fixes to the source, problem is solved. Recommend adjusting source to match.
anthonyattacks commentedon Sep 13, 2026
whoops, didn't mean to close (impatient clicking, saturday night)
C-Achard commentedon Sep 14, 2026
Hello @anthonyattacks,
Thanks for the report, this was fixed recently in #3508 (see 5cf10c9).
We will ideally include it in the next release.
Thanks and best,
Cyril