/roi_tanh_warping

Primary LanguagePythonMIT LicenseMIT

ibug.roi_tanh_warping

Differentiable implementation of various RoI-tanh warping methods.

Note: If you use this repository in your research, we kindly rquest you to cite the following paper:

@misc{lin2021roi,
      title={RoI Tanh-polar Transformer Network for Face Parsing in the Wild}, 
      author={Yiming Lin and Jie Shen and Yujiang Wang and Maja Pantic},
      year={2021},
      eprint={2102.02717},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Dependencies

How to Install

git clone https://github.com/hhj1897/roi_tanh_warping
cd roi_tanh_warping
pip install -e .

How to Test

python face_warping_test.py -v 0 -p 1 -r -k

Command-line arguments:

-v VIDEO: Index of the webcam to use (default=0) or
          path of the input video file
-x WIDTH: Width of the warped frames (default=256)
-y HEIGHT: Height of the warped frames (default=256)
-p POLAR: Use tanh-polar warping (when set to 1) or 
          tanh-circular warping (when set to 2) instead of 
          normal tanh warping (when set to 0, default)
-o OFFSET: Angular offset in degrees
-r: To also show restored frames
-c: To also compare with OpenCV-based reference implementation
-s: To use square-shaped detection box
-n: To use nearest-neighbour interpolation during restoration
-k: Keep aspect ratio in tanh-polar or tanh-circular warping
-d: Device to be used by the warping functions (default=cuda:0)
-b: Enable benchmark mode for CUDNN
-dt: Confidence threshold for face detection (default=0.8)
-dm: Face detection method, can be either RatinaFace (default)
     or S3FD
-dw: Weights to be loaded for face detection, can be either
     resnet50 or mobilenet0.25 when using RetinaFace
-dd: Device to be used for face detection (default=cuda:0)

There is also a script to specifically test the transform from ROI-tanh-polar space to the Cartesian ROI-tanh space (or in the reverse direction).

python tanh_polar_to_cartesian_test.py -v 0 -r -k

Command-line arguments:

-v VIDEO: Index of the webcam to use (default=0) or
          path of the input video file
-x WIDTH: Width of the warped frames (default=256)
-y HEIGHT: Height of the warped frames (default=256)
-o OFFSET: Angular offset in degrees
-r: To also show restored frames
-c: To also compare with OpenCV-based reference implementation
-t: To also compare with directly warped frames
-s: To use square-shaped detection box
-k: Keep aspect ratio in tanh-polar or tanh-circular warping
-i: To perform computation in the reverse direction
-d: Device to be used by the warping functions (default=cuda:0)
-b: Enable benchmark mode for CUDNN
-dt: Confidence threshold for face detection (default=0.8)
-dm: Face detection method, can be either RatinaFace (default)
     or S3FD
-dw: Weights to be loaded for face detection, can be either
     resnet50 or mobilenet0.25 when using RetinaFace
-dd: Device to be used for face detection (default=cuda:0)