当我尝试使用tensorflowjs_converter转换冻结的模型时 我收到此错误:
macbook-pro-6:tesla james $ tensorflowjs_converter --input_format = tf_frozen_model --output_node_names ='MobilenetV1 / Predictions / Reshape_1'--saved_model_tags = serve /retrained_graph.pb / web_model
(示例取自他们的github: https://github.com/tensorflow/tfjs-converter)
这是我得到的错误:
Using TensorFlow backend.
Traceback (most recent call last):
File "/Users/james/anaconda/bin/tensorflowjs_converter", line 7, in <module>
from tensorflowjs.converters.converter import main
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflowjs/__init__.py", line 21, in <module>
from tensorflowjs import converters
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflowjs/converters/__init__.py", line 22, in <module>
from tensorflowjs.converters.keras_tfjs_loader import deserialize_keras_model
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 25, in <module>
import keras
File "/Users/james/anaconda/lib/python2.7/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/Users/james/anaconda/lib/python2.7/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/Users/james/anaconda/lib/python2.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/Users/james/anaconda/lib/python2.7/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/Users/james/anaconda/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 15, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/node_def_pb2.py", line 15, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 15, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 15, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/Users/james/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 22, in <module>
serialized_pb=_b('\n/tensorflow/core/framework/resource_handle.proto\x12\ntensorflow\"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tBn\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01Z=github.com/tensorflow/tensorflow/tensorflow/go/core/framework\xf8\x01\x01\x62\x06proto3')
TypeError: __new__() got an unexpected keyword argument 'serialized_options'
我创建此.pb文件的方式是使用tensorflow进行诗人图像分类。它在Python中运行良好(我可以训练并创建.pb文件,甚至可以根据图像进行预测。我想将其转换为使用nodejs和tensorflowjs,但我似乎无法将.pb文件转换为tensorflowjs所需的格式
我决定修改并删除参数,如果我只是使用以下命令: tensorflowjs_converter-帮助 它会抛出与上面相同的错误,是吗?
答案 0 :(得分:0)
请尝试以下代码。
pip install -U protobuf
通过更新protobuf,您将能够解决上述问题。