A TensorFlow implementation of the Mnemonic Descent Method.

Overview

MDM

A Tensorflow implementation of the Mnemonic Descent Method.

Mnemonic Descent Method: A recurrent process applied for end-to-end face alignment
G. Trigeorgis, P. Snape, M. A. Nicolaou, E. Antonakos, S. Zafeiriou.
Proceedings of IEEE International Conference on Computer Vision & Pattern Recognition (CVPR'16).
Las Vegas, NV, USA, June 2016.

Installation Instructions

Menpo

We are an avid supporter of the Menpo project (http://www.menpo.org/) which we use in various ways throughout the implementation.

Please look at the installation instructions at:

http://www.menpo.org/installation/

TensorFlow

Follow the installation instructions of Tensorflow at and install it inside the conda enviroment you have created

https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#installing-from-sources

but use

git clone https://github.com/trigeorgis/tensorflow.git

as the TensorFlow repo. This is a fork of Tensorflow (#ff75787c) but it includes some extra C++ ops, such as for the extraction of patches around the landmarks.

Pretrained models

Disclaimer: The pretrained models can only be used for non-commercial academic purposes.

A pretrained model on 300W train set can be found at: https://www.doc.ic.ac.uk/~gt108/theano_mdm.pb

Training a model

Currently the TensorFlow implementation does not contain the same data augmnetation steps as we did in the paper, but this will be updated shortly.

    # Activate the conda environment where tf/menpo resides.
    source activate menpo
    
    # Start training
    python mdm_train.py --datasets='databases/lfpw/trainset/*.png:databases/afw/*.jpg:databases/helen/trainset/*.jpg'
    
    # Track the train process and evaluate the current checkpoint against the validation set
    python mdm_eval.py --dataset_path="./databases/ibug/*.jpg" --num_examples=135 --eval_dir=ckpt/eval_ibug  --device='/cpu:0' --checkpoint_dir=$PWD/ckpt/train
    
    python mdm_eval.py --dataset_path="./databases/lfpw/testset/*.png" --num_examples=300 --eval_dir=ckpt/eval_lfpw  --device='/cpu:0' --checkpoint_dir=$PWD/ckpt/train
    
    python mdm_eval.py --dataset_path="./databases/helen/testset/*.jpg" --num_examples=330 --eval_dir=ckpt/eval_helen  --device='/cpu:0' --checkpoint_dir=$PWD/ckpt/train
    
    # Run tensorboard to visualise the results
    tensorboard --logdir==$PWD/ckpt
Comments
  • Could you provide some hints on how to achieve the performance of your pre-trained model from scratch?

    Could you provide some hints on how to achieve the performance of your pre-trained model from scratch?

    Hi trigeorgis, thanks for your nice code. I have compiled and run the training process but found there is a big gap between the model trained myself and the one you provided. Data augmentation is one factor as you have mentioned in README. Is there any other reason for this gap? And could you provide some details about your data augmentation? Thanks.

    opened by windpls 16
  • Environment establishment

    Environment establishment

    I'm a newbie in Tensorflow. Currently, I'm trying to run the demo (Demo.ipynb) given in the source code. But I can't install Tensorflow (using the method: 'install from source' given in the Tensorflow official website) inside the Conda environment. Specifically, after I git clone from the repository (https://github.com/trigeorgis/tensorflow), I can't pass the configure operation (./configure), could you give me a detailed manual for the environment configuration? I've installed menpo package under Conda environment, what should I do next? How can I install Tensforflow from your repository into Conda environment, then I can import both Tensorflow and menpo libraries at the same time.

    opened by Dingyuan-Zheng 7
  • Update extract patches function in Tensorflow v0.10.0

    Update extract patches function in Tensorflow v0.10.0

    Hey, Georgis,

    I have question about moving extracting patches function in v0.10.0. But now it happen with problem that without shape function.

    Do you know how to define the shape function for the extracting patches?

    opened by ShownX 5
  • About the 300-w evaluation and dataset.

    About the 300-w evaluation and dataset.

    Hi, trigeorgis! Thanks for sharing your code. In the provided code, the pre-trained model get AUC of 41.04 which is much lower than 45.32(reported in the paper).

    And I can't find the right website to download test set of 300w. http://ibug.doc.ic.ac.uk/resources/facial-point-annotations/ only provide the full set.

    Thanks.

    opened by mariolew 4
  • Questions about the calculation of AUC

    Questions about the calculation of AUC

    Hi Trigeorgis,

    Thanks for your code. I have few questions about your AUC. In your code, https://github.com/trigeorgis/mdm/blob/fc8d011e0d7a34320aa0f971b60c9c0fa696e054/mdm_eval.py#L130 you calculate the auc via (errors < .08).mean()

    I think it should be the accuracy of the 0.08 threshold rather than AUC? Would you mind to let me how to calculate the [email protected]? Thanks a lot.

    opened by D-X-Y 1
  • AttributeError: 'PointCloud' object has no attribute '_group_label'

    AttributeError: 'PointCloud' object has no attribute '_group_label'

    Traceback (most recent call last): File "mdm_train.py", line 257, in train() File "mdm_train.py", line 82, in train data_provider.load_images(train_dirs) File "/home/hliu/Desktop/code/mdm/data_provider.py", line 150, in load_images group = group or im.landmarks[group]._group_label

    Hi, I get a problem on menpo. My menpo version is 0.8.1. I change the line 150 to " group = group or im.landmarks.keys()[0] ", it works. But the trained result is bad. I wonder if this is the reason.

    opened by gmh14 1
  • Bounding box annotations

    Bounding box annotations

    Dear colleagues,

    First of all I would like to congratulate you for your excellent work. I found a critical difference in the bounding boxes annotations. Why your annotations have been added with 1 pixel extra? For example: Image: afw/823016568_2.pts

    Your annotations: Bounding box: [ 397.500 445.500 397.500 709.500 685.500 709.500 685.500 445.500 ]

    Original annotations: bb_detector: 396.5,444.5,684.5,708.5

    On the other hand, how did you compute the bounding boxes for the 300w private images? Are you using a public face detector? I have not found it in the website. "As opposed to last year's Challenge (300-W 2013), in this version we will not provide any face detection initializations. Each system should detect the face in the image and then localize the facial landmarks."

    I look formard to your response.

    Best regards, Roberto Valle

    opened by bobetocalo 1
  • Replacing Custom Tensorflow Operation

    Replacing Custom Tensorflow Operation

    Hi trigeorgis,

    Instead of installing your custom TF repo to gain the custom extract image patches operation, I tried to write the operation in python with TF 1.0. This is what I came up with:

    `

            unset_patches = []
            for offset in tf.unstack(inits+dx, axis=1):
                batch_patches = tf.image.extract_glimpse(images, patch_shape, offset)
                unset_patches.append(batch_patches)
            # patches = tf.transpose(unset_patches, (1, 0, 2, 3, 4))
            patches = tf.stack(unset_patches, axis=1)
            patches = tf.reshape(patches, (batch_size * num_patches, patch_shape[0], patch_shape[1], num_channels))`
    

    From here training is able to run, but no learning takes place and losses hover around 1.0 for thousands of steps.

    Is there something I'm missing with this? Perhaps the optimizer can't back propagate losses through the operations taking place in python here, or there's an error in the code above when extracting and stacking these patches?

    Let me know if you'd like any more information.

    Help is greatly appreciated!

    opened by tuckerdarby 1
  • Missing tensorflow repo

    Missing tensorflow repo

    when I run "git clone [email protected]:trigeorgis/tensorflow.git", but with error output: "Cloning into 'tensorflow'... Permission denied (publickey). fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists." Does the tenforflow missing? Thank you!

    opened by Tao-Hu-L 1
  • Mapping of (face detection) bounding box points, from dlib output to final points used/stored in bbs folder.

    Mapping of (face detection) bounding box points, from dlib output to final points used/stored in bbs folder.

    @trigeorgis Can you provide the mapping performed on dlib output (for frontal face detection) to get bounding box used for facial key point prediction.

    opened by gp1313 1
  • Error

    Error "Model diverged with loss = NaN"

    To train the model, I have done as README on the github shows several times. But in all training processes, there are two cases that really confuse me:

    In the first case, the total training loss is close to zero when the training step comes to 16,000, and then the training process stops because of error "Model diverged with loss = NaN".

    In the second case, the total loss keeps Uunchanged after about 2,000 steps (Does it mean that the model has converged after 2,000 steps?), but the max step is set as 100,000. When the steps come to about 30,000, the training process also stops because of the same error: "Model diverged with loss = NaN"...

    I utilize the trained models in both cases to evaluate on the 300W, but the results are a little terrible...For example, the RMSE on lfpw testset is about 18.42%...   The only difference from original code is that the extract_patches.cc is compiled into a op library as extract_patches.so, and it is loaded to extract images patches in the training process.

    So, could you please explain the two cases to me and tell me how to train the mdm model exactly? I will really appreciate it!

    opened by MoExplorer 0
  • AttributeError: 'dict' object has no attribute 'lms'

    AttributeError: 'dict' object has no attribute 'lms'

    I have the question, File "/home/yeomja99/FaceLandmark/mdm-master/data_provider.py", line 38, in if group.lms.n_points == 68 AttributeError: 'dict' object has no attribute 'lms'

    so,how did you solve the problem? Thank you.

    opened by yeomja99 0
  • loss not decreasing and the gradients of weights are close to zero

    loss not decreasing and the gradients of weights are close to zero

    I use this code for training and with other dataset (which works very well with SDM method), but with MDM loss is decreasing few steps and then just stops, and weights started to be too small

    opened by katmatus 0
  • Question about mdm_model.py

    Question about mdm_model.py

    I am a newer of tensorflow. I got a problem on tf.image.extract_patches in mdm_model.py , and I can't found this function in my tensorflow1.10.0. Could you tell me what version of tensorflow you used in this Engineer and what is the function of this function.

    opened by lieeeee 2
Owner
null
Training vision models with full-batch gradient descent and regularization

Stochastic Training is Not Necessary for Generalization -- Training competitive vision models without stochasticity This repository implements trainin

Jonas Geiping 32 Jan 6, 2023
Plotting points that lie on the intersection of the given curves using gradient descent.

Plotting intersection of curves using gradient descent Webapp Link ---> What's the app about Why this app Plotting functions and their intersection. A

Divakar Verma 2 Jan 9, 2022
Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy.

Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy. Now with tensorflow 1.0 support. Evaluation usa

Marcel R. 349 Aug 6, 2022
TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

null 2.6k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Peter Lin 6.5k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting (RVM) English | 中文 Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specific

flow-dev 2 Aug 21, 2022
Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.

PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers 1 Using Colab Please notic

Hila Chefer 489 Jan 7, 2023
PyTorch implementation of the Deep SLDA method from our CVPRW-2020 paper "Lifelong Machine Learning with Deep Streaming Linear Discriminant Analysis"

Lifelong Machine Learning with Deep Streaming Linear Discriminant Analysis This is a PyTorch implementation of the Deep Streaming Linear Discriminant

Tyler Hayes 41 Dec 25, 2022
A PyTorch implementation of EventProp [https://arxiv.org/abs/2009.08378], a method to train Spiking Neural Networks

Spiking Neural Network training with EventProp This is an unofficial PyTorch implemenation of EventProp, a method to compute exact gradients for Spiki

Pedro Savarese 35 Jul 29, 2022
This is the official pytorch implementation of AutoDebias, an automatic debiasing method for recommendation.

AutoDebias This is the official pytorch implementation of AutoDebias, a debiasing method for recommendation system. AutoDebias is proposed in the pape

Dong Hande 77 Nov 25, 2022
Pytorch implementation of our method for high-resolution (e.g. 2048x1024) photorealistic video-to-video translation.

vid2vid Project | YouTube(short) | YouTube(full) | arXiv | Paper(full) Pytorch implementation for high-resolution (e.g., 2048x1024) photorealistic vid

NVIDIA Corporation 8.1k Jan 1, 2023
A Python implementation of the Locality Preserving Matching (LPM) method for pruning outliers in image matching.

LPM_Python A Python implementation of the Locality Preserving Matching (LPM) method for pruning outliers in image matching. The code is established ac

AoxiangFan 11 Nov 7, 2022
A PyTorch implementation of the baseline method in Panoptic Narrative Grounding (ICCV 2021 Oral)

A PyTorch implementation of the baseline method in Panoptic Narrative Grounding (ICCV 2021 Oral)

Biomedical Computer Vision @ Uniandes 52 Dec 19, 2022
Pytorch implementation of the unsupervised object discovery method LOST.

LOST Pytorch implementation of the unsupervised object discovery method LOST. More details can be found in the paper: Localizing Objects with Self-Sup

Valeo.ai 189 Dec 25, 2022
PyTorch implementation of our method for adversarial attacks and defenses in hyperspectral image classification.

Self-Attention Context Network for Hyperspectral Image Classification PyTorch implementation of our method for adversarial attacks and defenses in hyp

null 22 Dec 2, 2022
PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).

PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).

Ilya Kostrikov 3k Dec 31, 2022