I'm trying to get this PoseNet ResNet50 model working in Swift on iPhone XS. For that, I need to convert it to the tflite format. As I did not manage to find any direct way to do that; the most promising solution seems to be converting the tfjs model to keras_saved_model with the tfjs converter and then converting that to tflite using the TensorFlow Lite converter.
I struggle to convert to keras_saved_model. This is what I tried and how to reproduce the error:
- Download this model https://tfhub.dev/tensorflow/tfjs-model/posenet/resnet50/float/1/default/1
- Open the downloaded folder and rename
model-stride32.jsontomodel.json - Move back to the parent folder and run
tensorflowjs_wizard - Input the model path (
./posenet_resnet50_float_1_default_1) - You will see similar error to this:
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
I've also created this GitHub issue.
I appreciate any help on this:) Many thanks!