개요
TensorFlow Lite Model Maker 라이브러리는 맞춤 데이터 세트를 사용하여 TensorFlow Lite 모델을 학습시키는 프로세스를 간소화합니다. 전이 학습을 사용하여 필요한 학습 데이터의 양을 줄이고 학습 시간을 단축합니다.
지원되는 작업
Model Maker 라이브러리는 현재 다음 ML 작업을 지원합니다. 모델 학습 방법에 관한 가이드는 아래 링크를 클릭하세요.
| 지원되는 작업 | 작업 유틸리티 |
|---|---|
| 이미지 분류: 튜토리얼, api | 이미지를 사전 정의된 카테고리로 분류합니다. |
| 객체 감지: 튜토리얼, API | 실시간으로 객체를 감지합니다. |
| 텍스트 분류: 튜토리얼, API | 텍스트를 사전 정의된 카테고리로 분류합니다. |
| BERT 질문 답변: 튜토리얼, API | BERT를 사용하여 특정 컨텍스트에서 주어진 질문에 대한 답변을 찾습니다. |
| 오디오 분류: 튜토리얼, API | 오디오를 사전 정의된 카테고리로 분류합니다. |
| 권장사항: demo, api | 온디바이스 시나리오의 컨텍스트 정보를 기반으로 항목을 추천합니다. |
| 검색어: 튜토리얼, api | 데이터베이스에서 유사한 텍스트 또는 이미지를 검색합니다. |
작업이 지원되지 않는 경우 먼저 TensorFlow를 사용하여 전이 학습으로 TensorFlow 모델을 재학습 (이미지, 텍스트, 오디오와 같은 가이드 참고)하거나 처음부터 학습한 다음 TensorFlow Lite 모델로 변환하세요.
엔드 투 엔드 예
Model Maker를 사용하면 단 몇 줄의 코드로 맞춤 데이터 세트를 사용하여 TensorFlow Lite 모델을 학습시킬 수 있습니다. 예를 들어 이미지 분류 모델을 학습하는 단계는 다음과 같습니다.
from tflite_model_maker import image_classifier
from tflite_model_maker.image_classifier import DataLoader
# 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/')
자세한 내용은 이미지 분류 가이드를 참고하세요.
설치
Model Maker를 설치하는 방법에는 두 가지가 있습니다.
- 사전 빌드된 pip 패키지를 설치합니다.
pip install tflite-model-maker
나이틀리 버전을 설치하려면 다음 명령어를 따르세요.
pip install tflite-model-maker-nightly
- GitHub에서 소스 코드를 클론하고 설치합니다.
git clone https://github.com/tensorflow/examples
cd examples/tensorflow_examples/lite/model_maker/pip_package
pip install -e .
TensorFlow Lite Model Maker는 TensorFlow pip 패키지에 종속됩니다. GPU 드라이버의 경우 TensorFlow의 GPU 가이드 또는 설치 가이드를 참고하세요.
Python API 참조
API 참조에서 Model Maker의 공개 API를 확인할 수 있습니다.