在facenet的这一句报错了
saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)
Traceback (most recent call last):
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\importer.py", line 500, in _import_graph_def_internal
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 'gradients/InceptionResnetV1/Bottleneck/BatchNorm/cond/FusedBatchNorm_1_grad/FusedBatchNormGrad' has an _output_shapes attribute inconsistent with the GraphDef for output #3: Dimension 0 in both shapes must be equal, but are 0 and 128. Shapes are [0] and [128].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/28783/Desktop/mask/detect-and-recognize-mask-face-master/real_time.py", line 81, in <module>
main()
File "C:/Users/28783/Desktop/mask/detect-and-recognize-mask-face-master/real_time.py", line 39, in main
face_recognition = face2.Recognition()
File "C:\Users\28783\Desktop\mask\detect-and-recognize-mask-face-master\face2.py", line 42, in __init__
self.encoder = Encoder()
File "C:\Users\28783\Desktop\mask\detect-and-recognize-mask-face-master\face2.py", line 100, in __init__
facenet.load_model(facenet_model_checkpoint)
File "C:\Users\28783\Desktop\mask\detect-and-recognize-mask-face-master\facenet_src\facenet.py", line 363, in load_model
saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\training\saver.py", line 1584, in import_meta_graph
**kwargs)[0]
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\training\saver.py", line 1608, in _import_meta_graph_with_return_elements
**kwargs))
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\meta_graph.py", line 809, in import_scoped_meta_graph_with_return_elements
return_elements=return_elements)
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\util\deprecation.py", line 561, in new_func
return func(*args, **kwargs)
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\importer.py", line 408, in import_graph_def
producer_op_list=producer_op_list)
File "C:\Users\28783\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\importer.py", line 504, in _import_graph_def_internal
raise ValueError(str(e))
ValueError: Node 'gradients/InceptionResnetV1/Bottleneck/BatchNorm/cond/FusedBatchNorm_1_grad/FusedBatchNormGrad' has an _output_shapes attribute inconsistent with the GraphDef for output #3: Dimension 0 in both shapes must be equal, but are 0 and 128. Shapes are [0] and [128].
[ WARN:0@9.709] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (539) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
维度不匹配,看你的代码是自己写的还是找的开源项目代码,如果是别人的话,查一下路径是否正确,你这个可能是os.path.join(model_exp, meta_file)的路径不对导致数据为空,报错说的维度不匹配,也就是原本应该是128的长度你的变成0了
有可能是参数节点不匹配,可以通过直接恢复pd模型来解决
不会一样想问
报错提示你_output_shapes和GraphDef的第0维度的数据形状不一致,一个是0一个是128
维度0的的数据量没有匹配上
你的input参数类型和高函数需要的不匹配,你检查一下两个类型
输入给的不对。
https://blog.csdn.net/weixin_41012399/article/details/122412632