talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
435 stars 97 forks source link

Export fails with large number of predictions #1578

Closed roaldarbol closed 11 months ago

roaldarbol commented 1 year ago

Bug description

I am tracking really long videos (currently ~24 hours at 60fps), and the tracking is going well! However, I've hit a super unfortunate bug where I cannot export the predictions as pandas seems to run out of space trying to save them. It seems there is a solution, using the chunksize argument in to_csv (see this SO answer). So unfortunately I'm left with good data, but no way of extracting it currently.

Expected behaviour

I expect to have my file saved.

Actual behaviour

Takes a loooooong time, then eventually throws an error - see logs.

Your personal set up

Running on Windows 10, have 64GB RAM and an NVIDIA Quadro M5000 GPU.

Environment packages ``` # paste output of `pip freeze` or `conda list` here ```
Logs ``` Traceback (most recent call last): File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\gui\commands.py", line 337, in exportCSVFile self.execute(ExportAnalysisFile, all_videos=all_videos, csv=True) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\gui\commands.py", line 242, in execute command().execute(context=self, params=kwargs) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\gui\commands.py", line 138, in execute self.do_with_signal(context, params) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\gui\commands.py", line 162, in do_with_signal cls.do_action(context, params) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\gui\commands.py", line 1157, in do_action video=video, File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\io\format\csv.py", line 69, in write csv=True, File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\info\write_tracking_h5.py", line 438, in main write_csv_file(output_path, data_dict) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\sleap\info\write_tracking_h5.py", line 351, in write_csv_file tracks.to_csv(output_path, index=False) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\core\generic.py", line 3482, in to_csv storage_options=storage_options, File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\io\formats\format.py", line 1105, in to_csv csv_formatter.save() File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\io\formats\csvs.py", line 257, in save self._save() File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\io\formats\csvs.py", line 262, in _save self._save_body() File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\io\formats\csvs.py", line 300, in _save_body self._save_chunk(start_i, end_i) File "C:\Users\mr630\AppData\Local\mambaforge\envs\sleap\lib\site-packages\pandas\io\formats\csvs.py", line 316, in _save_chunk self.writer, File "pandas\_libs\writers.pyx", line 72, in pandas._libs.writers.write_csv_rows OSError: [Errno 28] No space left on device ```

Screenshots

How to reproduce

  1. Predict on massive video
  2. File > Export Analysis CSV...
talmo commented 11 months ago

Hi @roaldarbol,

I'm super sorry, it looks like your issue report fell through the cracks! November was a busy month for us, my apologies!

The CSV conversion is tricky since it's a very inefficient format to store pose data in, but this is still doable. Here's a workaround we've proposed in the past:

https://github.com/talmolab/sleap/discussions/1585#discussioncomment-7592938

Another approach might be to export it to an Analysis HDF5 file, either as an intermediate or as the format to use for your downstream analyses.

I'll move this over to our discussions as an idea for a suggested feature, but in the meantime, let us know if you're still running into issues!

Cheers,

Talmo