import tensorflow_model_optimization as tfmotmodel = tf.keras.Sequential([ ...])# Quantize the entire model.quantized_model = tfmot.quantization.keras.quantize_model(model)# Continue with training as usual.quantized_model.compile(...)quantized_model.fit(...)
data = ImageClassifierDataLoader.from_folder('flower_photos/')model = image_classifier.create(data)loss, accuracy = model.evaluate()model.export('flower_classifier.tflite', 'flower_label.txt', with_metadata=True)
// 1. Initializing the Model MyClassifierModel myImageClassifier = new MyClassifierModel(activity);// 2. Setting the input with a Bitmap called inputBitmapMyClassifierModel.Inputs inputs = myImageClassifier.createInputs();inputs.loadImage(inputBitmap));// 3. Running the modelMyClassifierModel.Outputs outputs = myImageClassifier.run(inputs);// 4. Retrieving the resultMap labeledProbability = outputs.getProbability();