A biblioteca do TensorFlow Lite Model Maker simplifica o processo de treinamento de um
Modelo do TensorFlow Lite usando um conjunto de dados personalizado. Ele usa o aprendizado por transferência para reduzir
a quantidade de dados de treinamento necessária e reduzir o tempo de treinamento.
Tarefas compatíveis
Atualmente, a biblioteca do Model Maker é compatível com as seguintes tarefas de ML. Clique no botão
links abaixo para guias sobre como treinar o modelo.
Pesquise textos ou imagens semelhantes em um banco de dados.
Se não houver suporte para suas tarefas, use primeiro
TensorFlow para treinar novamente um modelo do TensorFlow
com o aprendizado por transferência (seguindo guias como
imagens,
texto,
áudio) ou
treiná-lo do zero e depois convertê-lo no TensorFlow
Modelo Lite.
Exemplo completo
O Model Maker permite que você treine um modelo do TensorFlow Lite usando conjuntos de dados personalizados em
apenas algumas linhas de código. Por exemplo, estas são as etapas para treinar uma imagem
modelo de classificação.
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/')
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)."]]