mirror of
https://github.com/deepinsight/insightface.git
synced 2026-05-14 12:17:55 +00:00
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
import face_model
|
|
import argparse
|
|
import cv2
|
|
import sys
|
|
import numpy as np
|
|
|
|
parser = argparse.ArgumentParser(description='face model test')
|
|
# general
|
|
parser.add_argument('--image-size', default='112,112', help='')
|
|
parser.add_argument('--model', default='../models/model-r34-amf/model,0', help='path to load model.')
|
|
parser.add_argument('--age-model', default='../models2/model-r34-age/model,0', help='path to load model.')
|
|
parser.add_argument('--gender-model', default='../models2/model-r18-gender/model,0', help='path to load model.')
|
|
parser.add_argument('--gpu', default=0, type=int, help='gpu id')
|
|
parser.add_argument('--det', default=0, type=int, help='mtcnn option, 1 means using R+O, 0 means detect from begining')
|
|
parser.add_argument('--flip', default=0, type=int, help='whether do lr flip aug')
|
|
parser.add_argument('--threshold', default=1.24, type=float, help='ver dist threshold')
|
|
args = parser.parse_args()
|
|
|
|
model = face_model.FaceModel(args)
|
|
#img = cv2.imread('/raid5data/dplearn/lfw/Jude_Law/Jude_Law_0001.jpg')
|
|
img = cv2.imread('/raid5data/dplearn/megaface/facescrubr/112x112/Tom_Hanks/Tom_Hanks_54745.png')
|
|
img = model.get_input(img)
|
|
f1 = model.get_feature(img)
|
|
print(f1[0:10])
|
|
age = model.get_age(img)
|
|
print(age)
|
|
gender = model.get_gender(img)
|
|
print(gender)
|
|
sys.exit(0)
|
|
img = cv2.imread('/raid5data/dplearn/megaface/facescrubr/112x112/Tom_Hanks/Tom_Hanks_54733.png')
|
|
f2 = model.get_feature(img)
|
|
dist = np.sum(np.square(f1-f2))
|
|
print(dist)
|
|
sim = np.dot(f1, f2.T)
|
|
print(sim)
|
|
#diff = np.subtract(source_feature, target_feature)
|
|
#dist = np.sum(np.square(diff),1)
|