feedforward.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:facerecognition 作者: guoxiaolu 项目源码 文件源码
def get_embedding(img_path):
    img = misc.imread(img_path, mode='RGB')

    # judge alignment
    aligned = align.align(160, img, [0, 0, img.shape[1], img.shape[0]], landmarkIndices=landmarkIndices)


    img = facenet.prewhiten(img)
    img = np.expand_dims(img, axis=0)

    aligned = facenet.prewhiten(aligned)
    aligned = np.expand_dims(aligned, axis=0)


    # Run forward pass to calculate embeddings
    feed_dict = {images_placeholder: img, phase_train_placeholder: False}
    emb = sess.run(embeddings, feed_dict=feed_dict)

    # Run forward pass to calculate embeddings
    feed_dict_aligned = {images_placeholder: aligned, phase_train_placeholder: False}
    emb_aligned = sess.run(embeddings, feed_dict=feed_dict_aligned)

    return emb.ravel(), emb_aligned.ravel()

# # for test
# import os
# from time import time
# def main(dir_path):
#     img_all = os.listdir(dir_path)
#     for f in img_all:
#         start = time()
#         embedding_result = get_embedding(os.path.join(dir_path, f))
#         print time() - start
#         print embedding_result
#
# main('./data')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号