เครื่องสร้างโมเดลช่วยให้คุณฝึกโมเดล TensorFlow Lite โดยใช้ชุดข้อมูลที่กำหนดเองใน
ด้วยโค้ดเพียงไม่กี่บรรทัด ตัวอย่างเช่น ต่อไปนี้คือขั้นตอนการฝึกรูปภาพ
โมเดลการจัดประเภท
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/')
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 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)."]]