OpenCL implementation of waifu2x image upscaling
Latest commit 15979a5 Oct 4, 2015 @marcan Fix some brokenness with the YCbCr handling
Not entirely sure what's going on with PIL, but things seem to work if I
stick to uint8 types...


WARNING: This software is under active development and not yet inteded for production or use by end-users. It is not yet optimized. Tread with caution.

cl-waifu2x is an implementation of the waifu2x algorithm in OpenCL. It focuses on use of the neural network algorithm, not its training, and therefore it relies on models produced with the original waifu2x.

cl-waifu2x aims to be compatible with most mainstream OpenCL implementations, including GPU-based and CPU-based ones from major vendors.

Based on waifu2x by nagadomi.


  • Python 2.7
  • numpy
  • scipy
  • PIL (or Pillow)
  • PyOpenCL

And an OpenCL implementation.


$ python2 miku_small.png miku_small_cl.png models/scale2.0x_model.json
Choose platform:
[0] <pyopencl.Platform 'Intel(R) OpenCL' at 0x7fa4d7f10110>
[1] <pyopencl.Platform 'NVIDIA CUDA' at 0x7fa4d8026f80>
Choice [0]:
Set the environment variable PYOPENCL_CTX='' to avoid being asked again.
29004 pixels/sec
925359122 ops/sec

OpenCL implementations that are being used for testing:

  • Intel (CPU) (test platform: Intel Core i7 3820QM)
  • Nvidia (GPU) (test platform: Nvidia GeForce GTX 660M)


The current kernel is very dumb and not yet GPU-optimized. Performance is currently about equal on CPU and GPU, and about 6 times slower than the original waifu2x CUDA version on the same GPU, though also several times faster than the trivial single-threaded on the same CPU.