Git Product home page Git Product logo

Comments (7)

ymodak avatar ymodak commented on September 26, 2024

So those warnings pop up when you are trying to convert your keras model to tf lite? Can you please share complete code snippet?

from tflite-micro.

dexsr415 avatar dexsr415 commented on September 26, 2024

So those warnings pop up when you are trying to convert your keras model to tf lite? Can you please share complete code snippet?

Thanks for your reply!

I don't see this warning when i am trying to convert my keras model to tf lite.

this is my code (ref : https://www.tensorflow.org/lite/performance/post_training_integer_quant):

import tensorflow as tf
import numpy as np
import pathlib

load model

model_path = "E:/tensorflow_lite_example/MNINST_form_tensorflow/save_model/"

model=tf.keras.models.load_model(model_path) 

setting representative_data

(train_images, train_labels),(test_images,test_labels) = mnist.load_data()
train_images = train_images.astype(np.float32)/255.0

def representative_data_gen():
  for input_value in tf.data.Dataset.from_tensor_slices(train_images).batch(1).take(100):
    yield [input_value]

converter to tflite and quantization

converter = tf.lite.TFLiteConverter.from_keras_model(model)

converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_data_gen
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8
converter.inference_output_type = tf.int8

tflite_model_quant_int8 = converter.convert()

save tflite

tflite_models_dir = pathlib.Path("./tmp/tflie_test/")
tflite_models_dir.mkdir(exist_ok=True, parents=True)

tflite_model_quant_file = tflite_models_dir/"mnist_model_quant_int8.tflite"
tflite_model_quant_file.write_bytes(tflite_model_quant_int8)

from tflite-micro.

advaitjain avatar advaitjain commented on September 26, 2024

Since your goal is to use the ethos-u55, I would recommend starting with one of the TfLite Micro examples, such as the hello_world example.

I'm going to close the current issue, but please feel free to open a new one in the tflite-micro repository for any issues that you run into with the hello_world example.

Also, tagging @freddan80 in case there are any additional ethos-u55 specific examples that might be more relevant here.

from tflite-micro.

freddan80 avatar freddan80 commented on September 26, 2024

Thx for looping me in. We will check it out. Tagging @jenselofsson and @mansnils .

from tflite-micro.

mansnils avatar mansnils commented on September 26, 2024

@dexsr415 - As @advaitjain suggested, if you want to get started with Ethos-U55 and Vela in Tflite-micro you could have a look here:
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/cortex_m_corstone_300
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/network_tester
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/kernels/ethos_u

Running the network example will download Vela and convert the person detect int8 model.

In case you run into specific problems with Vela (outside the scope of the network example and benchmarks where Vela is used in Tflite-micro), you could raise an issue in https://community.arm.com/developer/tools-software/oss-platforms/f/machine-learning-forum/.
You can also use support-ml [email protected] for your issues if you are Arm License customer.

from tflite-micro.

dexsr415 avatar dexsr415 commented on September 26, 2024

@dexsr415 - As @advaitjain suggested, if you want to get started with Ethos-U55 and Vela in Tflite-micro you could have a look here:
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/cortex_m_corstone_300
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/network_tester
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/kernels/ethos_u

Running the network example will download Vela and convert the person detect int8 model.

In case you run into specific problems with Vela (outside the scope of the network example and benchmarks where Vela is used in Tflite-micro), you could raise an issue in https://community.arm.com/developer/tools-software/oss-platforms/f/machine-learning-forum/.
You can also use support-ml [email protected] for your issues if you are Arm License customer.

Thank you for your reply

I will check the information you gave.

Thank you so much

from tflite-micro.

dexsr415 avatar dexsr415 commented on September 26, 2024

I found that my question is similar to tensorflow/tensorflow#45090 (comment)

This problem seems to be related to dynamic size in keras.

from tflite-micro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.