umyelab / LabGym

Quantify user-defined behaviors.
GNU General Public License v3.0
64 stars 5 forks source link

Gradually increasing frame processing time #63

Closed low-bart closed 1 year ago

low-bart commented 1 year ago

Hello,

First I would just like to say thank you for creating such a powerful, easy to use, and well documented behavioral classifier. I am really impressed with the results we have gotten! Looking forward to citing you in our research.

I am using it to classify simple behaviors in videos that range from 90-120 minutes. I've noticed that the processing speed is lightning-fast for the analysis step during the first ~30,000 frames, in my case about 20-30 seconds for every 1000 frames processed. Beyond that point, it starts to slow down the more frames that have been processed, reaching about 5 minutes per 1000 frames as I approach the end of the video (~150,000 - 180,000 frames). Is there an option I missed to increase this processing time, perhaps saving the progress in chunks as I go rather than at the end of the processing? I've noticed nothing appears in the analysis results folder until a video has finished processing. If not it's no big deal, I was just curious.

Thank you!

yujiahu415 commented 1 year ago

Hi,

Thank you so much!! Really glad that LabGym can be useful for your research!

The cause it was getting slower at later stage but not at the beginning might be high memory-consumption. LabGym has been designed to process frames at constant speed (may have some small variance but should not be folds-differences). But since it stores information in memory, the memory consumption increases over time. When memory runs low, the overall performance / speed of the computer will drop significantly. This is more obvious if you set the virtual memory on the system drive, where most programs including python3 run from there.

Several ways to address this if the current analysis speed is far from satisfactory:

  1. Use larger memory. If you use Windows system and haven't set virtual memory but just use the RAM, you can set the virtual memory: https://www.windowscentral.com/how-change-virtual-memory-size-windows-10. Make sure to set the virtual memory on a drive that has large amount of free memory and is not the system drive like C:. I don't know the input shape of your trained Categorizer (behavior classifier). From my experience, analyzing a 2-hour video at 15-frames length and 32x32x1 of the Animation Analyzer may need over 250GB free memory.

  2. If the above option is not possible, you may trim the 2-hour video into several shorter clips.

  3. If the above two are not possible, you may consider reducing the input shape of the Categorizer. Simpler model may not always be worse, sometimes they actually perform better.

Hope these can help!

low-bart commented 1 year ago

Thanks for your suggestions! I did increase the paging file size for a secondary drive to fall between 200-300 GB and that did increase the processing speed to a satisfactory level. It is also a good suggestion to trim the video into shorter clips, which I might try at some point. I also have not experimented with reducing the input shape of the categorizer, so I will consider that as well. I appreciate the prompt response!