Hi,

 

After some troubles, finally I got the Image Stylization / Style Transfer presented in the Blog #2 running on the Raspberry Pi.

 

The first challenge was to install Torch and TorchVision on the Raspberry Pi. Looks like the binaries are not built for the armv7l architecture, so simply running

$ pip3 install torch torchvision

does not works.

 

Instead, the Torch and TorchVision need to build from source. I found a great article describing how to do this for Torch:

How to install PyTorch v4.0+ on Raspberry Pi-3B+, Odroids, and other ARM-based devices

 

Torch can built and installed as:

$ sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools

 

$ mkdir pytorch_install && cd pytorch_install

 

$ git clone --recursive https://github.com/pytorch/pytorch

 

$ cd pytorch

 

$ export NO_DISTRIBUTED=1

$ export NO_MKLDNN=1

$ export NO_NNPACK=1

$ export NO_QNNPACK=1


$ python3 setup.py build


$ sudo -E python3 setup.py install

Note: the build step takes about 12 hours and needs about 2 GB of additional swap space as the RPi is little bit low on RAM.

 

TorchVision can build similarly:

$ sudo apt-get install libjpeg-dev zlib1g-dev

 

 

$ git clone --recursive https://github.com/pytorch/vision

 

 

$ sudo apt-get install libjpeg-dev zlib1g-dev

After this the fast neural style example from pytorch / examples works, but because of the limited amount of RAM of the Rpi it works only for smaller resolution images.

Here is candy model applied to an image taken with RaspiCam, and down-scaled to 400x300:

model image:

The transformation takes about 1 minute on the Rpi.

 

Cheers,

Attila