Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: 30-face-tensorflow/face_project/FaceToolKit.py
new file: 30-face-tensorflow/face_project/detection/__init__.py new file: 30-face-tensorflow/face_project/detection/__init__.pyc new file: 30-face-tensorflow/face_project/detection/__pycache__/__init__.cpython-35.pyc new file: 30-face-tensorflow/face_project/detection/mtcnn/__init__.py new file: 30-face-tensorflow/face_project/detection/mtcnn/__init__.pyc new file: 30-face-tensorflow/face_project/detection/mtcnn/__pycache__/__init__.cpython-35.pyc new file: 30-face-tensorflow/face_project/detection/mtcnn/__pycache__/detect_face.cpython-35.pyc new file: 30-face-tensorflow/face_project/detection/mtcnn/det1.npy new file: 30-face-tensorflow/face_project/detection/mtcnn/det2.npy new file: 30-face-tensorflow/face_project/detection/mtcnn/det3.npy new file: 30-face-tensorflow/face_project/detection/mtcnn/detect_face.py
- Loading branch information
1 parent
45ed334
commit c7b8866
Showing
34 changed files
with
1,552 additions
and
0 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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
https://github.com/Alireza-Akhavan | ||
''' | ||
import tensorflow as tf | ||
import numpy as np | ||
from facenet import face | ||
|
||
class Verification: | ||
""" | ||
تطابق یا عدم تطابق دو چهره | ||
""" | ||
def __init__(self): | ||
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) | ||
self.session = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) | ||
self.images_placeholder = '' | ||
self.embeddings = '' | ||
self.phase_train_placeholder = '' | ||
self.embedding_size = '' | ||
self.session_closed = False | ||
|
||
def __del__(self): | ||
if not self.session_closed: | ||
self.session.close() | ||
|
||
def kill_session(self): | ||
self.session_closed = True | ||
self.session.close() | ||
|
||
def load_model(self, model): | ||
""" | ||
بارگذاری مدل | ||
این تابع حتما باید قبل از توابع دیگر فراخوانی شود. | ||
ورودی این تابع مسیرمدل از قبل آموزش دیده برای استخراج ویژگی است. | ||
""" | ||
face.load_model(model, self.session) | ||
|
||
def initial_input_output_tensors(self): | ||
""" | ||
ایجاد تنسورهای ورودی و خروجی از روی مدل لود شده توسط تابع | ||
load_model | ||
""" | ||
self.images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0") | ||
self.embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0") | ||
self.phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0") | ||
self.embedding_size = self.embeddings.get_shape()[1] | ||
|
||
|
||
def img_to_encoding(self, img, image_size): | ||
""" | ||
محاسبه embedding یک تصویر | ||
در اینجا یک وکتور 128 تایی برای هر تصویر | ||
""" | ||
image = face.make_image_tensor(img, False, False, image_size) | ||
|
||
feed_dict = {self.images_placeholder: image, self.phase_train_placeholder:False } | ||
emb_array = np.zeros((1, self.embedding_size)) | ||
emb_array[0, :] = self.session.run(self.embeddings, feed_dict=feed_dict) | ||
|
||
return np.squeeze(emb_array) | ||
|
Empty file.
Binary file not shown.
Binary file added
BIN
+128 Bytes
30-face-tensorflow/face_project/detection/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added
BIN
+134 Bytes
30-face-tensorflow/face_project/detection/mtcnn/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file added
BIN
+24.8 KB
30-face-tensorflow/face_project/detection/mtcnn/__pycache__/detect_face.cpython-35.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.