A simple face restoration TensorRT deployment solution, supporting StyleGAN, RTX3090 5.5ms+.
- Ubuntu 20.04+
- CUDA 11.0+
- TensorRT 8.0+
- OpenCV 4.2.0+
- CMake 3.1.0+
- Ubuntu 20.04 with CUDA 11.7 & TensorRT-8.2.4.2/TensorRT-8.6.1.6 on a RTX3090.
- Clone this repository
git clone https://github.com/bychen7/Face-Restoration-TensorRT
cd Face-Restoration-TensorRT
- Install the necessary dependencies
sudo apt-get update
sudo apt-get install cmake
sudo apt-get install libopencv-dev
- Modify lines 16 and 17 of the
CMakeLists.txt
file to reflect the path to your TensorRT installation
16 include_directories(the_path_to/TensorRT/include)
17 link_directories(the_path_to/TensorRT/lib)
- Build
mkdir build
cd build
cmake ..
make
- Download the
model
(BaiduPan pwd: yxt7 or Google Drive) and put them into../models
, then generate the TensorRT engine
./convert ../models/model.onnx -s ../models/model.engine
- Run
// The output will be saved as a file named res.jpg
./demo ../models/model.engine -i ../images/test.png
two inputs (data and weights) are allowed only in explicit-quantization mode.
If you encounter the above error when converting GPEN or GFPGAN models(Methods based on the StyleGAN architecture) to TensorRT engines, you can try the following approach, which multiplies the weights
and styles
on the input in an equivalent way. The left image shows the original approach, while the right image shows the modified approach.
If time permits, I will update the overall TensorRT deployment solution, including face detection, face alignment, face parsing, and more. This is just an engineering matter, as the core ModulatedConv2d deployment has already been published. Thank you for reading.