sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
272 stars 137 forks source link

Can´t pickle_thread.RLocj objects error while Creating Location Heatmaps #323

Closed rnrpereira closed 5 months ago

rnrpereira commented 5 months ago

Hi everyone, I'm having this error after trying to produce a heatmap from a single animal tracking:

Traceback (most recent call last): File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/tkinter/__init__.py", line 1705, in __call__ return self.func(*args) File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/site-packages/simba/ui/pop_ups/heatmap_location_pop_up.py", line 58, in <lambda> self.run_single_video_btn = Button(self.run_single_video_frm, text='Create single video', fg='blue', command=lambda: self.__create_heatmap_plots(multiple_videos=False)) File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/site-packages/simba/ui/pop_ups/heatmap_location_pop_up.py", line 130, in __create_heatmap_plots heatmapper_clf.run() File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/site-packages/simba/plotting/heat_mapper_location_mp.py", line 275, in run for cnt, result in enumerate(pool.imap(constants, frame_arrays, chunksize=self.multiprocess_chunksize)): File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/multiprocessing/pool.py", line 735, in next raise value File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/multiprocessing/pool.py", line 424, in _handle_tasks put(task) File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/multiprocessing/connection.py", line 206, in send self._send_bytes(_ForkingPickler.dumps(obj)) File "/Applications/anaconda3/envs/SIMBA/lib/python3.6/multiprocessing/reduction.py", line 51, in dumps cls(buf, protocol).dump(obj) TypeError: can't pickle _thread.RLock objects

My setup: 1) iMac OSX 10.13.6 | python 3.6.15 2) 264 x 352 video (30fps), 0.44 px/mm 3) One animal tracking (white on black background using deeplabcut) 4) I was able to analyze and generate a video with ROI tracking but got this error during heatmap generation.

Any ideas as for the reason i'm getting this?

thanx a lot, Rodrigo

sronilsson commented 5 months ago

Hi @rnrpereira! It is likely a bug, for reporting this one I appreciate it.

Which version of SimBA so you see with pip show simba-uw-tf-dev?

PS. For anyone bumping into the TypeError: can't pickle _thread.RLock objects error: This can happen when passing objects with a python logger attribute as a constant to a multiprocessing method. Drop the logger from the object and it should run.

rnrpereira commented 5 months ago

Thank you for your reply. I am using SIMBA v.1.82.4 R.

sronilsson commented 5 months ago

Thanks @rnrpereira - I've updated the code, if you update simba with pip install simba-uw-tf-dev --upgrade can you let me know how it runs and looks and if the error still appears on your end?

rnrpereira commented 5 months ago

It's working fine! thank you... R.

sronilsson commented 5 months ago

Thanks for letting me know!