La bibliothèque TensorFlow Lite Model Maker simplifie le processus d'entraînement
Modèle TensorFlow Lite utilisant un ensemble de données personnalisé Il utilise l'apprentissage par transfert pour réduire
la quantité de données d'entraînement
requise et raccourcir la durée d'entraînement.
Tâches compatibles
La bibliothèque Model Maker accepte actuellement les tâches de ML ci-dessous. Cliquez sur l'icône
cliquez sur les liens ci-dessous pour découvrir comment entraîner le modèle.
Recherchez un texte ou une image similaire dans une base de données.
Si vos tâches ne sont pas prises en charge, veuillez d'abord utiliser
TensorFlow pour réentraîner un modèle TensorFlow
grâce à l'apprentissage par transfert (les guides suivants
imagestexte,
audio) ou
l'entraîner à partir de zéro, puis la convertir en TensorFlow
Modèle Lite.
Exemple de bout en bout
Model Maker vous permet d'entraîner un modèle TensorFlow Lite à l'aide d'ensembles de données personnalisés dans
que quelques lignes de code. Par exemple, voici les étapes à suivre pour entraîner une image
modèle de classification.
fromtflite_model_makerimportimage_classifierfromtflite_model_maker.image_classifierimportDataLoader# Load input data specific to an on-device ML app.data=DataLoader.from_folder('flower_photos/')train_data,test_data=data.split(0.9)# Customize the TensorFlow model.model=image_classifier.create(train_data)# Evaluate the model.loss,accuracy=model.evaluate(test_data)# Export to Tensorflow Lite model and label file in `export_dir`.model.export(export_dir='/tmp/')
Les API publiques de Model Maker sont disponibles dans la section API
référence.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/01/14 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/01/14 (UTC)."],[],[],null,["# TensorFlow Lite Model Maker\n\nOverview\n--------\n\nThe TensorFlow Lite Model Maker library simplifies the process of training a\nTensorFlow Lite model using custom dataset. It uses transfer learning to reduce\nthe amount of training data required and shorten the training time.\n\nSupported Tasks\n---------------\n\nThe Model Maker library currently supports the following ML tasks. Click the\nlinks below for guides on how to train the model.\n\n| Supported Tasks | Task Utility |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|\n| Image Classification: [tutorial](./image_classification), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/image_classifier) | Classify images into predefined categories. |\n| Object Detection: [tutorial](./object_detection), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/object_detector) | Detect objects in real time. |\n| Text Classification: [tutorial](./text_classification), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/text_classifier) | Classify text into predefined categories. |\n| BERT Question Answer: [tutorial](./question_answer), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/question_answer) | Find the answer in a certain context for a given question with BERT. |\n| Audio Classification: [tutorial](./audio_classification), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/audio_classifier) | Classify audio into predefined categories. |\n| Recommendation: [demo](https://github.com/tensorflow/examples/blob/master/tensorflow_examples/lite/model_maker/demo/recommendation_demo.py), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/recommendation) | Recommend items based on the context information for on-device scenario. |\n| Searcher: [tutorial](./text_searcher), [api](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker/searcher) | Search for similar text or image in a database. |\n\nIf your tasks are not supported, please first use\n[TensorFlow](https://www.tensorflow.org/guide) to retrain a TensorFlow model\nwith transfer learning (following guides like\n[images](https://www.tensorflow.org/tutorials/images/transfer_learning),\n[text](https://www.tensorflow.org/official_models/fine_tuning_bert),\n[audio](https://www.tensorflow.org/tutorials/audio/transfer_learning_audio)) or\ntrain it from scratch, and then [convert](../../models/convert) it to TensorFlow\nLite model.\n\nEnd-to-End Example\n------------------\n\nModel Maker allows you to train a TensorFlow Lite model using custom datasets in\njust a few lines of code. For example, here are the steps to train an image\nclassification model. \n\n from tflite_model_maker import image_classifier\n from tflite_model_maker.image_classifier import DataLoader\n\n # Load input data specific to an on-device ML app.\n data = DataLoader.from_folder('flower_photos/')\n train_data, test_data = data.split(0.9)\n\n # Customize the TensorFlow model.\n model = image_classifier.create(train_data)\n\n # Evaluate the model.\n loss, accuracy = model.evaluate(test_data)\n\n # Export to Tensorflow Lite model and label file in `export_dir`.\n model.export(export_dir='/tmp/')\n\nFor more details, see the [image classification guide](./image_classification).\n\nInstallation\n------------\n\nThere are two ways to install Model Maker.\n\n- Install a prebuilt pip package.\n\n pip install tflite-model-maker\n\nIf you want to install nightly version, please follow the command: \n\n pip install tflite-model-maker-nightly\n\n- Clone the source code from GitHub and install.\n\n git clone https://github.com/tensorflow/examples\n cd examples/tensorflow_examples/lite/model_maker/pip_package\n pip install -e .\n\nTensorFlow Lite Model Maker depends on TensorFlow [pip\npackage](https://www.tensorflow.org/install/pip). For GPU drivers, please refer\nto TensorFlow's [GPU guide](https://www.tensorflow.org/install/gpu) or\n[installation guide](https://www.tensorflow.org/install).\n\nPython API Reference\n--------------------\n\nYou can find out Model Maker's public APIs in [API\nreference](https://www.tensorflow.org/lite/api_docs/python/tflite_model_maker)."]]