yinguobing / butterfly

A lightweight python module to load TensorFlow frozen model (a single pb file).
MIT License
7 stars 2 forks source link

demo.py运行错误 #2

Open fanofpal opened 4 years ago

fanofpal commented 4 years ago

您好!我最近在尝试复现您的cnn_facial_landmark工作,根据您cnn_facial_landmark项目中的源码训练了模型,后来找到butterfly项目中的demo.py是推演模型的程序。 根据要求,我用tensorflow官方提供的freeze_graph.py文件对cnn_facial_landmark保存的模型(savedmodel.pb)进行了固化,生成的freeze_graphy.pb文件查看其结构得到下面的表

butterfly/encoded_image_string_tensor
butterfly/map/Shape
butterfly/map/strided_slice/stack
butterfly/map/strided_slice/stack_1
...
butterfly/layer6/logits/bias/read
butterfly/layer6/logits/MatMul
butterfly/layer6/logits/BiasAdd

于是我认为input_node是butterfly/encoded_image_string_tensor,output_node是butterfly/layer6/logits/BiasAdd,但将其作为参数输入,试图在一个视频中运行时出现了错误:

ValueError: Cannot feed value of shape (1, 360, 640, 3) for Tensor 'butterfly/encoded_image_string_tensor:0', which has shape '(?,)'

我认为这可能是在模型固化那一步出现的问题,尝试用model.ckpt等文件来重新获得固化模型,结果与pb文件获得模型结构有差别,但在运行demo.py时也出现了基本一样的错误 请问问题出在哪里,该如何解决?

yinguobing commented 4 years ago

这里的输入从名字上看是base64编码的图像文件,所以shape是“(?,)”。

训练代码提供的导出选项有参数来指定input格式是raw_tensor,检查一下。

如果可能的话尽量使用keras分支训练,更简单。

fanofpal commented 4 years ago

您好,将raw_tensor的参数修改为True之后顺利运行了。对于128128尺寸输入的图片也有很好的标注效果,但是对于非128128输入的图片,标注点多少存在一点偏移,请问这个应该怎么解决呢?