TensorFlow Lite 모델 메이커

개요

TensorFlow Lite Model Maker 라이브러리는 사용자 지정 데이터 세트를 사용하여 TensorFlow Lite 모델을 교육하는 프로세스를 단순화합니다. 전이 학습을 사용하여 필요한 훈련 데이터의 양을 줄이고 훈련 시간을 단축합니다.

지원되는 작업

Model Maker 라이브러리는 현재 다음 ML 작업을 지원합니다. 모델 학습 방법에 대한 가이드를 보려면 아래 링크를 클릭하세요.

지원되는 작업 작업 유틸리티
이미지 분류: 튜토리얼 , API 이미지를 미리 정의된 범주로 분류합니다.
객체 감지: 튜토리얼 , API 실시간으로 물체를 감지합니다.
텍스트 분류: 튜토리얼 , API 텍스트를 미리 정의된 범주로 분류합니다.
BERT 질문 답변: 튜토리얼 , API BERT를 사용하여 주어진 질문에 대한 특정 맥락에서 답을 찾으십시오.
오디오 분류: 튜토리얼 , API 오디오를 미리 정의된 범주로 분류합니다.
권장 사항: 데모 , API 온디바이스 시나리오에 대한 컨텍스트 정보를 기반으로 아이템을 추천합니다.
검색자: 튜토리얼 , API 데이터베이스에서 유사한 텍스트 또는 이미지를 검색합니다.

작업이 지원되지 않는 경우 먼저 TensorFlow 를 사용하여 전이 학습으로 TensorFlow 모델을 재교육하거나( images , text , audio 와 같은 가이드를 따름) 처음부터 교육한 다음 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 가이드 또는 설치 가이드 를 참조하세요.

파이썬 API 참조

API 참조 에서 Model Maker의 공개 API를 찾을 수 있습니다.