TensorFlow Lite Model Maker

개요

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

지원되는 작업

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

지원되는 작업 작업 유틸리티
이미지 분류: 튜토리얼 , API 이미지를 미리 정의된 카테고리로 분류합니다.
객체 감지: 튜토리얼 , API 실시간으로 물체를 감지합니다.
텍스트 분류: 튜토리얼 , API 텍스트를 미리 정의된 카테고리로 분류합니다.
BERT 질문 답변: 튜토리얼 , API BERT를 사용하여 특정 질문에 대한 특정 맥락에서 답변을 찾으세요.
오디오 분류: 튜토리얼 , API 오디오를 미리 정의된 카테고리로 분류합니다.
권장사항: 데모 , 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

Nightly 버전을 설치하려면 다음 명령을 따르십시오.

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를 확인할 수 있습니다.