# lab5 **Repository Path**: johnny1128/lab5 ## Basic Information - **Project Name**: lab5 - **Description**: test5test5 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-09 - **Last Updated**: 2022-06-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # # 使用TensorFlow Lite Model Maker生成图像分类器模型 1. 打开pycharm,安装程序运行所需的一些库 > pip install tflite-model-maker ![图片](./image/1.jpg) 2. 模型训练代码 import os import numpy as np import matplotlib.pyplot as plt import tensorflow as tf assert tf.__version__.startswith('2') from tflite_model_maker import model_spec from tflite_model_maker import image_classifier from tflite_model_maker.config import ExportFormat from tflite_model_maker.config import QuantizationConfig from tflite_model_maker.image_classifier import DataLoader image_path = tf.keras.utils.get_file( 'flower_photos.tgz', 'https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz', extract=True) image_path = os.path.join(os.path.dirname(image_path), 'flower_photos') data = DataLoader.from_folder(image_path) train_data, test_data = data.split(0.9) inception_v3_spec = image_classifier.ModelSpec( uri='https://storage.googleapis.com/tfhub-modules/tensorflow/efficientnet/lite0/feature-vector/2.tar.gz') inception_v3_spec.input_image_shape = [240, 240] model = image_classifier.create(train_data, model_spec=inception_v3_spec) loss, accuracy = model.evaluate(test_data) model.export(export_dir='.') 3. 运行代码 ![图片](./image/2.jpg) 生成model.tflite文件 ![图片](./image/3.jpg) 4. 将model.tflite文件在实验3中运行 ![图片](./image/4.jpg) ![输入图片说明](images/29.png)