Skip to content

Qengineering/GFPGAN-ncnn-Raspberry-Pi-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GFPGAN Raspberry Pi 4

output image

Face reconstruction with the ncnn framework.

License

Paper: https://arxiv.org/pdf/2101.04061.pdf

Special made for a bare Raspberry Pi 4, see Q-engineering deep learning examples


Dependencies.

To run the application, you have to:

  • A raspberry Pi 4 with a 32 or 64-bit operating system. It can be the Raspberry 64-bit OS, or Ubuntu 18.04 / 20.04. Install 64-bit OS
  • The latest version of Tencent ncnn framework installed. Install ncnn
  • OpenCV 64 bit installed. Install OpenCV 4.5
  • Code::Blocks installed. ($ sudo apt-get install codeblocks)
  • 👉 Download and unzip the deep learning models gfpgan-ncnn-20221225T122514Z-001.zip file from Gdrive.

Installing the app.

To extract and run the network in Code::Blocks
$ mkdir MyDir
$ cd MyDir
$ wget https://github.com/Qengineering/GFPGAN-ncnn-Raspberry-Pi-4/archive/refs/heads/main.zip
$ unzip -j master.zip
Remove master.zip, LICENSE and README.md as they are no longer needed.
$ rm master.zip
$ rm LICENSE
$ rm README.md

Your MyDir folder must now look like this:

.
├── Duo.png
├── Girl.jpg
├── Julia.jpg
├── Man.png
├── GFPGAN.cbp
├── include
│   ├── face.h
│   ├── gfpgan.h
│   └── realesrgan.h
├── models
│   ├── encoder.bin
│   ├── encoder.param
│   ├── real_esrgan.bin
│   ├── real_esrgan.param
│   ├── style.bin
│   ├── yolov5-blazeface.bin
│   └── yolov5-blazeface.param
└── src
    ├── face.cpp
    ├── gfpgan.cpp
    ├── main.cpp
    └── realesrgan.cpp

Running the app.

To run the application, load the GFPGAN.cbp project file into Code::Blocks. More information? Follow the instructions at Hands-On.

In main.cpp, you have two branches: one for images with only one face (Girl.jpg) and another for scenes with more faces (Duo.png). The software determines which branch to follow. Especially the second branch, the one with the reconstruction of the whole scene, can take quite a long time. Mostly more than a few minutes.

For best results, do not use jpeg compressed images. Strong jpeg compression generates typical artefacts to which the super-resolution algorithm does not respond well.

output image (colorization done by https://github.com/Qengineering/ncnn-Colorization_Raspberry-Pi-4)

output image

output image


Thanks.

A more than special thanks to FeiGeChuanShu, who adapted the ncnn framework for this app.


More info.

Colorful Image Colorization FeiGeChuanShu
Colorful Image Colorization Project Page by Xintao Wang, Yu Li, Honglun Zhang, Ying Shan.


paypal