nncase icon indicating copy to clipboard operation
nncase copied to clipboard

Convert QUANTIZED_UINT8 tflite model to kmodel

Open arthurkafer opened this issue 4 years ago • 3 comments

I have a Google AutoML trained model exported to tflite and I wanted to convert it to kmodel to use it on a Sipeed Maixpy board. Even if I try to force an inference type, it doesn't understand and it gave me some errors.

This is the command I'm running: ./ncc/ncc -i tflite -o k210model --dataset /content/images /content/model.tflite /content/model.kmodel

and this is the error it returns:

Fatal: expect FLOAT32 tensor but got UINT8, use '--inference_type=FLOAT' when converting via toco.
System.InvalidOperationException: expect FLOAT32 tensor but got UINT8, use '--inference_type=FLOAT' when converting via toco.
   at NnCase.Converter.Converters.TfLiteExtensions.GetTensor[T](Model model, Tensor tensor) in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 420
   at NnCase.Converter.Converters.TfLiteToGraphConverter.ConvertConv2d(Operator op) in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 142
   at NnCase.Converter.Converters.TfLiteToGraphConverter.ConvertOperator(Operator op) in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 69
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at NnCase.Converter.Converters.TfLiteToGraphConverter.Convert() in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 34
   at NnCase.Cli.Program.Main(String[] args) in D:\Work\Repository\nncase\src\NnCase.Cli\Program.cs:line 113
   at NnCase.Cli.Program.<Main>(String[] args)

Is there a command or an option that converts the UINT8 model to kmodel?

Thanks in advance

arthurkafer avatar Feb 19 '21 20:02 arthurkafer

Hi, if you have found a solution to this, please let us know.

cezarchirila avatar Mar 04 '21 11:03 cezarchirila

I couldn't find, had to change my approach for the problem and tried to train my model without AutoML. The results are obviously worse but it is what it is. Still waiting for a contributor to answer if it's possible or not

arthurkafer avatar Mar 04 '21 12:03 arthurkafer

Currently only FLOAT models are supported.

sunnycase avatar Apr 03 '21 03:04 sunnycase