-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from arsfutura/develop
v0.1 Former-commit-id: 2f4915b
- Loading branch information
Showing
40 changed files
with
463 additions
and
859 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .face_recogniser import face_recogniser_factory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .mtcnn import MTCNNAligner | ||
|
||
|
||
def aligner_factory(args): | ||
return MTCNNAligner() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Oops, something went wrong.