GitPedia

6DRepNet

Official Pytorch implementation of 6DRepNet: 6D Rotation representation for unconstrained head pose estimation.

From thohemp·Updated June 16, 2026·View on GitHub·

**6DRepNet** is a Official Pytorch implementation of 6DRepNet: 6D Rotation representation for unconstrained head pose estimation. The project is written primarily in Python, distributed under the MIT License license, first published in 2022. Key topics include: 6d, aflw2000, analysis, biwi, estimation.

PWC
PWC
Hugging Face Spaces

<div align="center"> 6D Rotation Representation for Unconstrained Head Pose Estimation (Pytorch) </div>

<p align="center"> <img src="https://github.com/thohemp/archive/blob/main/6DRepNet2.gif" alt="animated" /> </p>

Citing

If you find our work useful, please cite the paper:

BibTeX
@ARTICLE{10477888, author={Hempel, Thorsten and Abdelrahman, Ahmed A. and Al-Hamadi, Ayoub}, journal={IEEE Transactions on Image Processing}, title={Toward Robust and Unconstrained Full Range of Rotation Head Pose Estimation}, year={2024}, volume={33}, number={}, pages={2377-2387}, keywords={Head;Training;Predictive models;Pose estimation;Quaternions;Three-dimensional displays;Training data;Head pose estimation;full range of rotation;rotation matrix;6D representation;geodesic loss}, doi={10.1109/TIP.2024.3378180}}
BibTeX
@INPROCEEDINGS{9897219, author={Hempel, Thorsten and Abdelrahman, Ahmed A. and Al-Hamadi, Ayoub}, booktitle={2022 IEEE International Conference on Image Processing (ICIP)}, title={6d Rotation Representation For Unconstrained Head Pose Estimation}, year={2022}, volume={}, number={}, pages={2496-2500}, doi={10.1109/ICIP46576.2022.9897219}}

Updates

18.09.2023

13.09.2022

  • 6DRepNet is now avaiable as pip package for even more accessable usage: pip3 install SixDRepNet

20.06.2022

  • 6DRepNet has been accepted to ICIP 2022.

29.05.2022

  • Simplified training script
  • Updated default training configuration for more robust results

<div align="center"> Paper</div>

Thorsten Hempel and Ahmed A. Abdelrahman and Ayoub Al-Hamadi, "6D Rotation Representation for Unconstrained Head Pose Estimation", accepted to ICIP 2022. [ResearchGate][Arxiv]

<div align="center"> Abstract</div>

In this paper, we present a method for unconstrained end-to-end head pose estimation. We address the problem of ambiguous rotation labels by introducing the rotation matrix formalism for our ground truth data and propose a continuous 6D rotation matrix representation for efficient and robust direct regression. This way, our method can learn the full rotation appearance which is contrary to previous approaches that restrict the pose prediction to a narrow-angle for satisfactory results. In addition, we propose a geodesic distance-based loss to penalize our network with respect to the <img src="https://render.githubusercontent.com/render/math?math=\textit{SO}(3)"> manifold geometry. Experiments on the public AFLW2000 and BIWI datasets demonstrate that our proposed method significantly outperforms other state-of-the-art methods by up to 20%.


<div align="left">

Trained on 300W-LP, Test on AFLW2000 and BIWI

Full RangeYawPitchRollMAEYawPitchRollMAE
HopeNet (<img src="https://render.githubusercontent.com/render/math?math=\alpha"> =2)N6.476.565.446.165.176.983.395.18
HopeNet (<img src="https://render.githubusercontent.com/render/math?math=\alpha"> =1)N6.926.645.676.414.816.613.274.90
FSA-NetN4.506.084.645.074.274.962.764.00
HPEN4.806.184.875.283.125.184.574.29
QuatNetN3.975.623.924.502.945.494.014.15
WHENet-VN4.445.754.314.833.604.102.733.48
WHENetY/N5.116.244.925.423.994.393.063.81
TriNetY4.045.774.204.674.114.763.053.97
FDNN3.785.613.884.424.524.702.563.93
6DRepNetY3.634.913.37<ins>3.97</ins>3.244.482.68<ins> 3.47</ins>
</div> <div align="left">

BIWI 70/30

YawPitchRollMAE
HopeNet (<img src="https://render.githubusercontent.com/render/math?math=\alpha"> =1)3.293.393.003.23
FSA-Net2.894.293.603.60
TriNet2.933.042.442.80
FDN3.003.982.883.29
6DRepNet2.692.922.36<ins>2.66 </ins>
</div>

Fine-tuned Models

Fine-tuned models can be download from here: https://drive.google.com/drive/folders/1V1pCV0BEW3mD-B9MogGrz_P91UhTtuE_?usp=sharing

<div align="center"> Quick Start: </div>

Pip install:

sh
pip3 install sixdrepnet

Example usage:

py
# Import SixDRepNet from sixdrepnet import SixDRepNet import cv2 # Create model # Weights are automatically downloaded model = SixDRepNet() img = cv2.imread('/path/to/image.jpg') pitch, yaw, roll = model.predict(img) model.draw_axis(img, yaw, pitch, roll) cv2.imshow("test_window", img) cv2.waitKey(0)

Setting it up your own:

sh
git clone https://github.com/thohemp/6DRepNet cd 6DRepNet

Set up a virtual environment:

sh
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt # Install required packages

In order to run the demo scripts you need to install the face detector

sh
pip install git+https://github.com/elliottzheng/face-detection.git@master

Camera Demo:

sh
python ./sixdrepnet/demo.py --snapshot 6DRepNet_300W_LP_AFLW2000.pth \ --cam 0

<div align="center"> Test/Train 3DRepNet </div>

Preparing datasets

Download datasets:

  • 300W-LP, AFLW2000 from here.

  • BIWI (Biwi Kinect Head Pose Database) from here

Store them in the datasets directory.

For 300W-LP and AFLW2000 we need to create a filenamelist.

python create_filename_list.py --root_dir datasets/300W_LP

The BIWI datasets needs be preprocessed by a face detector to cut out the faces from the images. You can use the script provided here. For 7:3 splitting of the BIWI dataset you can use the equivalent script here. We set the cropped image size to 256.

Testing:

sh
python test.py --batch_size 64 \ --dataset AFLW2000 \ --data_dir datasets/AFLW2000 \ --filename_list datasets/AFLW2000/files.txt \ --snapshot output/snapshots/1.pth \ --show_viz False

Training

Download pre-trained RepVGG model 'RepVGG-B1g2-train.pth' from here and save it in the root directory.

sh
python sixdrepnet/train.py

Deploy models

For reparameterization the trained models into inference-models use the convert script.

python convert.py input-model.tar output-model.pth

Inference-models are loaded with the flag deploy=True.

python
model = SixDRepNet(backbone_name='RepVGG-B1g2', backbone_file='', deploy=True, pretrained=False)

Contributors

Showing top 6 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from thohemp/6DRepNet via the GitHub API.Last fetched: 6/20/2026