Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caching speeds up batch processing #40

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

swell-d
Copy link
Contributor

@swell-d swell-d commented Dec 29, 2024

Hi,
Thanks for the updates on the library.
Could you please check if caching would help speed up the batch processing of a large number of images?
I haven't delved into your code and don't understand what it does, but maybe it could help.

@BrianPugh
Copy link
Collaborator

I'll slightly tweak this PR and then merge it in. We need to use lru_cache instead of cache with a reasonably short cache size (lets say... 8)? Otherwise this could use an unexpected amount of memory. Additionally, since we are returning a numpy array (mutable) we should attempt to make it immutable by setting the write flag to false.

slice_chunk is a super fast function and barely benefits from caching. On my computer, a typical uncached call is about 5uS slower while a typical cached call is about 5uS faster. So let's not cache this one.

All the others are pretty fast (typically just a few mS), but would be faster if cached. This would be beneficial if processing a lot of images of the same resolution. For our test/demo image, this would make subsequent processing of same-resolution images ~25% faster.

@swell-d
Copy link
Contributor Author

swell-d commented Jan 2, 2025

Super!

@BrianPugh
Copy link
Collaborator

if you're processing a large dataset (or any use in general, I suppose), make sure you have opencv installed! If it's installed, py360 will internally use its faster warping functions.

Thanks for the PR!

@swell-d
Copy link
Contributor Author

swell-d commented Jan 2, 2025

Hi Brian,
Of course I'm using opencv. Here's my website: https://360-for-you.com/
In all the time users have already processed more than 100,000+ panoramas with your library.
Thank you a lot!

@BrianPugh BrianPugh mentioned this pull request Jan 2, 2025
@BrianPugh
Copy link
Collaborator

awesome! I also just added sampler caching; so now all possible intermediate calculations are now cached for same input/output resolution processing.

@BrianPugh BrianPugh merged commit 4d37f59 into sunset1995:master Jan 2, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants