cceyda / image-checker

Fast Image Integrity Checker: Scan for corrupted images using Nvidia DALI
MIT License
19 stars 2 forks source link

Benchmarking against Pillow-SIMD w/libjpeg-turbo #1

Open willprice opened 3 years ago

willprice commented 3 years ago

Hey @cceyda, I came here via https://cceyda.github.io/blog/dali/cv/image_processing/2020/11/10/nvidia_dali.html nice blog post! Did you use pillow-simd built against libjpeg-turbo, or just the vanilla version? I find libjpeg-turbo speeds things up considerably (even compared to opencv it's 3x fast in my benchmarks). Also check out simplejpeg which so far seems to be the fasted jpeg loader I've yet to come across.

cceyda commented 3 years ago

Thank you for your comment 😄 I have re-run and updated the benchmarks in benchmark_jpeg_decode.ipynb adding libjpeg-turbo check.

Also not yet included in those benchmarks; I tried out nvidia-dali on an A100 GPU (which is supposed to be faster than a TITAN X ,for reasons I mention in my blog post) And got the results like below: image (*pil-simd(turbo)) Mind you this is on a different machine than the results in the previous notebook, and I still need to profile what is happening BUT...

It looks like it is always faster to use DALI > torchvision > pil-simd(turbo) > pil-simd > pil

Haven't had the chance to try simplejpeg yet but I think It would perform similarly to pil-simd(turbo) since it is based on it.

willprice commented 3 years ago

Hi @cceyda, I had a little play around last night and came up with these findings https://twitter.com/will_price_94/status/1365057412902891521 It's interesting you found torchvision quicker than pillow-simd with libjpeg-turbo. I found the opposite. I've found simplejpeg to be the fastest of the CPU options. I'd be curious if we can figure out why we have conflicting results on pillow-simd. Your benchmark is more realistic, whereas mine is just decoding the same image repeatedly.

cceyda commented 3 years ago

Nice~ I have upgraded my script to include OpenCV and simplejpeg. It looks like simplejpeg is FASTER than pillow-simd and torchvision(0.8.2)! 🤔 Thanks for sharing 😄 FYI: My benchmarks are on bytes->Tensor because that was my use case. Feel free to adapt it to yours

willprice commented 3 years ago

Good to know you also found simplejpeg fast too. It's a great library that deserves wider use! The author also has an interesting project called augpy that has NvJPEG decoding.