【Python】Pillow-SIMD:Pillow 加速版

Backto Python Index

SIMD 代表 single instruction, multiple data, 充分壓榨多核(Intel) CPU 的性能. 常用的 CPU SIMD 指令集有
MMX, SSE-SSE4, AVX, AVX2, AVX512, NEON 等。

Pillow-SIMD 就是 應用 SIMD 加速的 Pillow,100% API cover, production ready。默認 SSE4 編譯,提供 AVX2 支持。

已加速的常見操作:

Resize (convolution-based resampling): SSE4, AVX2
Gaussian and box blur: SSE4
Alpha composition: SSE4, AVX2
RGBA → RGBa (alpha premultiplication): SSE4, AVX2
RGBa → RGBA (division by alpha): SSE4, AVX2
RGB → L (grayscale): SSE4
3x3 and 5x5 kernel filters: SSE4, AVX2
Split and get_channel: SSE4

Pillow Performance 中可以看出,SIMD 優化後的操作,速度全面優於 OpenCV. 但是 OpenCV 畢竟是大哥大,全面、均衡、穩定。

安裝

# must remove existed pillow first.
$ pip uninstall pillow
# install SSE4 version
$ pip install pillow-simd
# install AVX2 version
$ CC="cc -mavx2" pip install -U --force-reinstall pillow-simd
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章