Skip to content

Commit

Permalink
Updated README fixed python2 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
1adrianb committed Sep 18, 2017
1 parent 0ec5f1a commit a533c6f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 11 deletions.
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.
/opt/conda/bin/conda clean -ya
ENV PATH /opt/conda/envs/pytorch-py35/bin:$PATH
RUN conda install --name pytorch-py35 -c soumith magma-cuda80
RUN conda install pytorch torchvision cuda80 -c soumith

# This must be done before pip so that requirements.txt is available
WORKDIR /opt/pytorch
COPY . .

RUN TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \
pip install -v .

# Install face-alignment package
# Install face-alignment package
WORKDIR /workspace
RUN chmod -R a+w /workspace
RUN git clone https://github.com/1adrianb/face-alignment
WORKDIR /workspace/face-alignment
RUN pip install -r requirements.txt
RUN python setup.py install
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,68 @@ Build using [FAN](https://www.adrianbulat.com)'s state-of-the-art deep learning

Note: For the lua version check [here](https://github.com/1adrianb/2D-and-3D-face-alignment). For numerical evaluations it is recommended to use the lua version which uses indentical models with the ones evaluated in the paper.

[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![Build Status](https://travis-ci.com/1adrianb/face-alignment.svg)](https://travis-ci.com/1adrianb/face-alignment)

## Features

#### Detect 2D facial landmarks in pictures

<p align='center'>
<img src='docs/images/2dlandmarks.png' title='3D-FAN-Full example' style='max-width:600px'></img>
</p>

```python
import face_alignment
import scipy.io as io

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, enable_cuda=True, flip_input=False)

input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
```

#### Detect 3D facial landmarks in pictures

<p align='center'>
<img src='https://www.adrianbulat.com/images/image-z-examples.png' title='3D-FAN-Full example' style='max-width:600px'></img>
</p>

```python
import face_alignment
import scipy.io as io

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, enable_cuda=True, flip_input=False)

input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
```

#### Find all faces present in a given image

```python
import face_alignment
import scipy.io as io

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, enable_cuda=False, flip_input=False)

input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.detect_faces(input)
```

#### Process an entire directory in one go

```python
import face_alignment
import scipy.io as io

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, enable_cuda=False, flip_input=False)

input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.process_folder('../test/assets/', all_faces=True)
```

Please also see the ``examples`` folder

## Instalation

### Requirements
Expand Down Expand Up @@ -92,6 +142,10 @@ docker build -t face-alignment .

While here the work is presented as a black-box, if you want to know more about the intrisecs of the method please check the original paper either on arxiv or my [webpage](https://www.adrianbulat.com).

## Contributions

All contributions are welcomed. If you encounter any issue (including examples of images where it fails) feel free to open an issue.

## Citation

```
Expand Down
Binary file added docs/images/2dlandmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions face_alignment/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import glob
import dlib
Expand Down
4 changes: 3 additions & 1 deletion face_alignment/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import sys
import time
Expand Down Expand Up @@ -69,7 +70,8 @@ def transform(point, center, scale, resolution, invert=False):

if invert:
t = torch.inverse(t)
new_point = (t @ _pt)[0:2]

new_point = (torch.matmul(t,_pt))[0:2]

return new_point.int()

Expand Down

0 comments on commit a533c6f

Please sign in to comment.