Skip to content

A simple face restoration TensorRT deployment solution.

Notifications You must be signed in to change notification settings

lschaupp/Face-Restoration-TensorRT

 
 

Repository files navigation

Face Restoration TensorRT

A simple face restoration TensorRT deployment solution, supporting StyleGAN, RTX3090 5.5ms+.

Requirements

  • Ubuntu 20.04+
  • CUDA 11.0+
  • TensorRT 8.0+
  • OpenCV 4.2.0+
  • CMake 3.1.0+

Tested environments

  • Ubuntu 20.04 with CUDA 11.7 & TensorRT-8.2.4.2/TensorRT-8.6.1.6 on a RTX3090.

Bulid and Run

  1. Clone this repository
git clone https://github.com/bychen7/Face-Restoration-TensorRT
cd Face-Restoration-TensorRT
  1. Install the necessary dependencies
sudo apt-get update
sudo apt-get install cmake
sudo apt-get install libopencv-dev
  1. 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)
  1. Build
mkdir build
cd build
cmake ..
make
  1. 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
  1. Run
// The output will be saved as a file named res.jpg
./demo ../models/model.engine -i ../images/test.png

ModulatedConv2d

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.

MISC

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.

Acknowledgments

About

A simple face restoration TensorRT deployment solution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 70.1%
  • Python 24.0%
  • CMake 5.8%
  • Other 0.1%