Unsupported Weights Error when converting .tflight model

I am trying to convert a .tflite model file using the Dataflow Compiler Studio. When parsing I get a UnsupportedQuantizedWeightsError - please advise the best way to compile the model.

Status code: 1 [info] Translation started on Tensorflow model scene_classsifier_v5 Traceback (most recent call last): File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/bin/hailo", line 8, in <module> sys.exit(main()) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/main.py", line 111, in main ret_val = client_command_runner.run() File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py", line 68, in run return self._run(argv) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/tools/cmd_utils/base_utils.py", line 89, in _run return args.func(args) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py", line 188, in run runner = self._parse(net_name, args, tensor_shapes) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/tools/parser_cli.py", line 243, in _parse runner.translate_tf_model( File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_common/states/states.py", line 16, in wrapped_func return func(self, *args, **kwargs) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py", line 1222, in translate_tf_model parser.translate_tf_model( File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_model_optimization/tools/subprocess_wrapper.py", line 122, in parent_wrapper func(self, *args, **kwargs) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py", line 96, in translate_tf_model parsing_results = self.parse_model_to_hn( File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py", line 351, in parse_model_to_hn fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py", line 79, in convert_model self._create_layers() File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py", line 34, in _create_layers self._add_direct_layers() File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/edge_nn_translator.py", line 111, in _add_direct_layers self._layer_callback_from_vertex(vertex) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/tflite_translator/tflite_translator.py", line 146, in _layer_callback_from_vertex layer, consumed_vertices, activation = create_layer_from_vertex(LayerType.conv, vertex) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/tflite_translator/tflite_layer_creator.py", line 79, in create_layer_from_vertex return _create_convolutional_layer(vertex) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/tflite_translator/tflite_layer_creator.py", line 150, in _create_convolutional_layer conv_attrs, vertex_kernel, bias = vertex.get_conv_info() File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/tflite_translator/tflite_graph.py", line 266, in get_conv_info self.verify_quantized_weights([kernel, bias]) File "/home/akara-robotics/Desktop/Akara/occucam/hailo_model_zoo/hailo/lib/python3.10/site-packages/hailo_sdk_client/model_translator/tflite_translator/tflite_graph.py", line 307, in verify_quantized_weights raise UnsupportedQuantizedWeightsError(error_msg) hailo_sdk_client.model_translator.exceptions.UnsupportedQuantizedWeightsError: Model weights are quantized to [dtype('int8'), dtype('float32')], which is currently unsupported. Please use a model with float32/16 only, mixed precision is not supported as well.```

Hi @niamh.donnelly,
Welcome to the community.

I think that in this case the error is quite straight forward:

Please make sure that on the conversion to tflite you’re keeping the weights in float32 format. We have a tutorial about it in the DFC user guide.

That’s great, can you link me to that tutorial?

@Nadav We managed to get this working but I would like to view the document you referenced. Can you link me to it?

Sure,
Here’s the link:
Common Conversion Methods from Tensorflow to Tensorflow Lite

Another option is to launch this Jupyter based tutorial from an the DFC virtual-env by launching the tutorial hailo tutorial and selecting the parsing tutorial.