-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,358 additions
and
686 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
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,38 +1,56 @@ | ||
import os | ||
import numpy as np | ||
from scipy.signal import convolve2d | ||
from argparse import ArgumentParser | ||
|
||
|
||
class BioCapsuleGenerator: | ||
def __signature_extraction(self, feature): | ||
lvl1 = convolve2d(feature.reshape(32, 16), np.ones( | ||
(5, 5)) / 25., mode="same", boundary="wrap") | ||
lvl1 = convolve2d( | ||
feature.reshape(32, 16), | ||
np.ones((5, 5)) / 25.0, | ||
mode="same", | ||
boundary="wrap", | ||
) | ||
|
||
lvl2 = feature.reshape(32, 16) - lvl1 | ||
signature = np.around(np.average(lvl2, axis=1) * 100.).astype(int) % 9 | ||
|
||
signature = np.around(np.average(lvl2, axis=1) * 100.0).astype(int) % 9 | ||
|
||
return signature | ||
|
||
def __key_generation(self, signature): | ||
key = np.empty((0,)) | ||
|
||
for sig in signature: | ||
np.random.seed(sig) | ||
key = np.append(key, np.random.choice(2, 16)) | ||
|
||
key = (key * 2) - 1 | ||
|
||
return key | ||
|
||
def biocapsule(self, user_feature, rs_feature): | ||
user_signature = self.__signature_extraction(user_feature) | ||
user_key = self.__key_generation(user_signature) | ||
|
||
rs_signature = self.__signature_extraction(rs_feature) | ||
rs_key = self.__key_generation(rs_signature) | ||
return np.multiply(user_feature, rs_key) + np.multiply(rs_feature, user_key) | ||
|
||
bc = np.multiply(user_feature, rs_key) + np.multiply( | ||
rs_feature, user_key | ||
) | ||
|
||
return bc | ||
|
||
def biocapsule_batch(self, user_features, rs_feature): | ||
rs_signature = self.__signature_extraction(rs_feature) | ||
rs_key = self.__key_generation(rs_signature) | ||
|
||
for i in range(user_features.shape[0]): | ||
user_signature = self.__signature_extraction(user_features[i]) | ||
user_key = self.__key_generation(user_signature) | ||
user_features[i] = np.multiply(user_features[i], rs_key) + \ | ||
np.multiply(rs_feature, user_key) | ||
|
||
user_features[i] = np.multiply( | ||
user_features[i], rs_key | ||
) + np.multiply(rs_feature, user_key) | ||
|
||
return user_features |
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 |
---|---|---|
@@ -1 +1 @@ | ||
from face_models.face_model import ArcFaceModel, FaceNetModel | ||
from .face_model import ArcFaceModel, FaceNetModel |
Oops, something went wrong.