Skip to content

Commit

Permalink
Merge pull request #1 from arsfutura/develop
Browse files Browse the repository at this point in the history
v0.1

Former-commit-id: 2f4915b
  • Loading branch information
Luka Dulčić authored Jun 19, 2019
2 parents 177a76b + de85d10 commit da1ad11
Show file tree
Hide file tree
Showing 40 changed files with 463 additions and 859 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "facenet"]
path = facenet
url = git@github.com:arsfutura/facenet-pytorch.git
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### `face_recognition.py`
```
usage: Script for recognising faces on picture. Output of this script is json with list of people on picture and base64 encoded picture which has bounding boxes of people.
[-h] (--image-path IMAGE_PATH | --image-bs64 IMAGE_BS64)
--classifier-path CLASSIFIER_PATH
optional arguments:
-h, --help show this help message and exit
--image-path IMAGE_PATH
Path to image file.
--image-bs64 IMAGE_BS64
Base64 representation of image.
--classifier-path CLASSIFIER_PATH
Path to serialized classifier.
```

#

### `real_time_face_detection.py`
```
usage: Script for real-time face recognition. [-h]
[--classifier-path CLASSIFIER_PATH]
optional arguments:
-h, --help show this help message and exit
--classifier-path CLASSIFIER_PATH
Path to serialized classifier.
```
Empty file.
2 changes: 0 additions & 2 deletions arsfutura-face-similarity/constants.py

This file was deleted.

15 changes: 0 additions & 15 deletions arsfutura-face-similarity/dataset.py

This file was deleted.

45 changes: 0 additions & 45 deletions arsfutura-face-similarity/predict.py

This file was deleted.

33 changes: 0 additions & 33 deletions arsfutura-face-similarity/real_time_face_detection.py

This file was deleted.

Empty file.
175 changes: 0 additions & 175 deletions arsfutura-face-similarity/util/align-dlib.py

This file was deleted.

1 change: 1 addition & 0 deletions arsfutura_face_recognition/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .face_recogniser import face_recogniser_factory
10 changes: 10 additions & 0 deletions arsfutura_face_recognition/aligner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from abc import ABC, abstractmethod


class Aligner(ABC):
@abstractmethod
def align(self, img):
pass

def __call__(self, *args, **kwargs):
return self.align(*args, **kwargs)
5 changes: 5 additions & 0 deletions arsfutura_face_recognition/aligner/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .mtcnn import MTCNNAligner


def aligner_factory(args):
return MTCNNAligner()
10 changes: 10 additions & 0 deletions arsfutura_face_recognition/aligner/mtcnn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from facenet import MTCNN
from . import Aligner


class MTCNNAligner(Aligner):
def __init__(self):
self.mtcnn = MTCNN(keep_all=True)

def align(self, img):
return self.mtcnn(img)
10 changes: 10 additions & 0 deletions arsfutura_face_recognition/classifier/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from abc import ABC, abstractmethod


class FaceClassifier(ABC):
@abstractmethod
def predict(self, face_embedding):
pass

def __call__(self, *args, **kwargs):
return self.predict(*args, **kwargs)
10 changes: 10 additions & 0 deletions arsfutura_face_recognition/classifier/classifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from . import FaceClassifier
import pickle


class FaceClassifierImpl(FaceClassifier):
def __init__(self, model_path):
self.le, self.model = pickle.load(open(model_path, 'rb'))

def predict(self, face_embedding):
return self.le.inverse_transform(self.model.predict(face_embedding))
5 changes: 5 additions & 0 deletions arsfutura_face_recognition/classifier/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .classifier import FaceClassifierImpl


def classifier_factory(args):
return FaceClassifierImpl(args.classifier_path)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def main(directory, name, test):
try:
main(directory, args.person, args.test)
except KeyboardInterrupt:
print "Photo session done for {} :)".format(args.person)
print("Photo session done for {} :)".format(args.person))
9 changes: 9 additions & 0 deletions arsfutura_face_recognition/dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import numpy as np


def load_data():
return np.loadtxt('../embeddings.txt'), np.loadtxt('../labels.txt', dtype=np.str)


if __name__ == '__main__':
print(load_data())
Loading

0 comments on commit da1ad11

Please sign in to comment.