怎么把PoseNet ResNet50 tfjs模型转换成tflite?

时间:2020-06-19 12:25:27

标签: tensorflow tensorflow.js

我正在尝试让此PoseNet ResNet50 model在iPhone XS上的Swift中工作。为此,我需要将其转换为tflite格式。由于我没有找到任何直接的方法来做到这一点;最有前途的解决方案似乎是使用tfjs converter将tfjs模型转换为keras_saved_model,然后使用TensorFlow Lite converter将其转换为tflite。

我很难转换为keras_saved_model。这是我尝试过的方法以及如何重现错误的方法:

Welcome to TensorFlow.js Converter.
? Please provide the path of model file or the directory that contains model files. 
If you are converting TFHub module please provide the URL.  ./posenet_resnet50_float_1_default_1
Traceback (most recent call last):
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/bin/tensorflowjs_wizard", line 8, in <module>
    sys.exit(pip_main())
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/site-packages/tensorflowjs/converters/wizard.py", line 590, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/site-packages/tensorflowjs/converters/wizard.py", line 598, in main
    run(dry_run)
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/site-packages/tensorflowjs/converters/wizard.py", line 410, in run
    input_params[common.INPUT_PATH])
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/site-packages/tensorflowjs/converters/wizard.py", line 107, in detect_input_format
    if get_tfjs_model_type(filename) == common.TFJS_LAYERS_MODEL_FORMAT:
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/site-packages/tensorflowjs/converters/wizard.py", line 67, in get_tfjs_model_type
    data = json.load(f)
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/Users/daniel/anaconda3/envs/tfjs-graph-converter/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

TensorFlow.js 1.7.2
TensorFlow 2.1.0
macOS Catalina 10.15.5

我还创建了this GitHub issue

感谢您的帮助:)非常感谢!

0 个答案:

没有答案