Exemplo n.º 1
0
import vggface
from pprint import pprint
import tensorflow as tf
input_placeholder = tf.placeholder(tf.float32, shape=(1, 224, 224, 3))
network = vggface.VGGFace()

ses = tf.InteractiveSession()
network.load(ses, input_placeholder)

output = network.eval(
    feed_dict={input_placeholder: vggface.load_image('test/ak.png')})[0]
pprint(
    sorted([(v, network.names[k]) for k, v in enumerate(output)],
           reverse=True)[:10])

output = network.eval(
    feed_dict={input_placeholder: vggface.load_image('test/IMG_0647.jpg')})[0]
pprint(
    sorted([(v, network.names[k]) for k, v in enumerate(output)],
           reverse=True)[:10])
Exemplo n.º 2
0
  Setup opencv and dlib

'''

face_cascade = cv2.CascadeClassifier(
    'openCVDetector/haarcascade_frontalface_default.xml')
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(
    "dlibDetector/shape_predictor_68_face_landmarks.dat")
'''

  Setup tensorflow network

'''
# input_placeholder = tf.placeholder(tf.float32, shape=(1, 224, 224, 3))
network = vggface.VGGFace(BATCH_SIZE)
ses = tf.InteractiveSession()
saver = tf.train.Saver()
'''

  Quadruple loss implementation

'''

fp_fi_img = tf.placeholder(tf.float32, [BATCH_SIZE, 224, 224, 3])
fp_si_img = tf.placeholder(tf.float32, [BATCH_SIZE, 224, 224, 3])
sp_fi_img = tf.placeholder(tf.float32, [BATCH_SIZE, 224, 224, 3])
sp_si_img = tf.placeholder(tf.float32, [BATCH_SIZE, 224, 224, 3])

fp_fi = tf.nn.l2_normalize(network.network_eval(fp_fi_img), 1)
fp_si = tf.nn.l2_normalize(network.network_eval(fp_si_img), 1)