一、定位脚本文件
定位到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,精确率不是很高,此处只做学习记录,工作继续进行,不做优化。