Anaconad+Ubuntu16.4下tensorflow+facenet人脸识别(六)测试pb文件

一、定位脚本文件

定位到src文件夹下的compare.py脚本

在155-127行,定义了传参的函数


def parse_arguments(argv):
    parser = argparse.ArgumentParser()
    
    parser.add_argument('model', type=str, 
        help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')
    parser.add_argument('image_files', type=str, nargs='+', help='Images to compare')
    parser.add_argument('--image_size', type=int,
        help='Image size (height, width) in pixels.', default=160)
    #44->32
    parser.add_argument('--margin', type=int,
        help='Margin for the crop around the bounding box (height, width) in pixels.', default=32)
    parser.add_argument('--gpu_memory_fraction', type=float,
        help='Upper bound on the amount of 
parse_arguments(argv)

model:模型的路径
image_files:测试图片的路径
image_size:测试图片的尺寸
margin:填充的margin
gpu_memory_fraction:gup占用量

这里注意两点:
1.image_size参数的设置,要与训练的图片尺寸大小一致
2.测试图片的格式为.jpg.png

进行测试的图片

在这里插入图片描述

二、运行脚本

python3 compare.py /home/gqw/models/facenet/20201214-094502/graph.pb /media/gqw/Sduty/Linux_tensorflow/test/hua/hua1.png /media/gqw/Sduty/Linux_tensorflow/test/hua/hua2.png

报错

The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’

原因

查找资料,推测原因为版本不匹配

解决

conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python 

值得注意的是,和在tensorflow1.9进行人脸检测时一样,这次在卸载opencv时,依然更新了许多包
在这里插入图片描述
再次执行

成功!

我们看一下运行结果
在这里插入图片描述
因为我们只训练了一个epoch,精确率不是很高,此处只做学习记录,工作继续进行,不做优化。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值