我要将body-pix移植到Python和C ++,并想将tensorflow.js的body-pix预先训练的模型导出到tensorflow冻结图中。有可能吗?
我已经下载了以下文件,并尝试使用tensorflowjs_converter进行转换,但是没有用。
结果在这里。
$ tensorflowjs_converter --input_format tfjs_layers_model --output_format keras posenet_mobilenet_025_partmap/model.json test.h5
Traceback (most recent call last):
File "/home/xxx/anaconda3/envs/tfjs_test2/bin/tensorflowjs_converter", line 10, in <module>
sys.exit(main())
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 368, in main
FLAGS.output_path)
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflowjs/converters/converter.py", line 169, in dispatch_tensorflowjs_to_keras_h5_conversion
model = keras_tfjs_loader.load_keras_model(config_json_path)
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 218, in load_keras_model
use_unique_name_scope=use_unique_name_scope)
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 65, in _deserialize_keras_model
model = keras.models.model_from_json(json.dumps(model_topology_json))
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py", line 96, in model_from_json
return deserialize(config, custom_objects=custom_objects)
File "/home/xxx/anaconda3/envs/tfjs_test2/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 81, in deserialize
layer_class_name = config['class_name']
KeyError: 'class_name'
转换器版本在这里。
tensorflowjs 1.0.1
Dependency versions:
keras 2.2.4-tf
tensorflow 2.0.0-dev20190405
在Ubuntu 16.04 LTS和anaconda 3。 我已经尝试过tensorflowjs 0.8.5,但是也没有用。
如果您告诉我如何进行转换,将很有帮助。 keras格式或tensorflow冻结图都可以。我认为两者可以相互转换。
答案 0 :(得分:7)
例如:https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/resnet50/float/model-stride16.json
https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/resnet50/float/manifest.json
来自https://github.com/ajaichemmanam/tfjs-to-tf
tfjs_graph_converter路径/ to / js / model路径/to/frozen/model.pb
这里是将POSENET转换为keras h5模型的示例。 https://github.com/tensorflow/tfjs/files/3943875/posenet.zip 用相同的方法可以使用bodypix模型并将其转换。