TensorFlow Lite에서 LiteRT로 이전

기기 내 AI를 위한 Google의 고성능 런타임에 관한 모든 새로운 개발은 LiteRT에서만 이루어집니다. TensorFlow Lite 패키지를 사용하는 애플리케이션은 계속 작동하지만 모든 새 업데이트는 LiteRT 패키지에만 포함됩니다. LiteRT API는 TF Lite API와 동일한 메서드 이름을 포함하므로 LiteRT로 이전할 때 세부적인 코드 변경이 필요하지 않습니다.

패키지 이름 변경에 관한 자세한 내용은 특정 플랫폼에 관한 다음 이전 가이드를 참고하세요.

Android로 이전

TensorFlow Lite를 사용하여 Android 애플리케이션을 이전하려면 종속 항목을 org.tensorflow:tensorflow-lite에서 com.google.ai.edge.litert로 바꿉니다. LiteRT Maven 저장소에는 다음 패키지가 포함되어 있습니다.

build.gradle 종속 항목에서 다음과 같이 변경할 수 있습니다.

dependencies {
  ...
  implementation `com.google.ai.edge.litert:litert:1.0.1`
}

Play 서비스

Play 서비스 런타임의 LiteRT는 계속해서 play-services-tflite 종속 항목을 사용합니다. 앱에서 이미 TensorFlow Lite와 함께 Play 서비스 런타임을 사용하고 있다면 코드를 변경할 필요가 없습니다.

Play 서비스에서 LiteRT를 사용하려면 build.gradle 종속 항목에 다음을 추가합니다.

dependencies {
...
    // LiteRT dependencies for Google Play services
    implementation 'com.google.android.gms:play-services-tflite-java:16.4.0'
    // Optional: include LiteRT Support Library
    implementation 'com.google.android.gms:play-services-tflite-support:16.4.0'
...
}

Python으로 이전

TensorFlow Lite를 사용하여 Python 코드를 이전하려면 PIP 패키지를 tflite-runtime에서 ai-edge-litert로 바꿉니다.

PIP를 사용하여 LiteRT를 설치합니다.

$ python3 -m pip install ai-edge-litert

다음을 사용하여 LiteRT를 가져옵니다.

from ai_edge_litert.interpreter import Interpreter
interpreter = Interpreter(model_path=args.model_file)

기타 라이브러리

iOS용 Swift 및 Objective-C SDK, C++ SDK, 작업 라이브러리, 모델 제작 도구 라이브러리는 TensorFlow Lite API에 계속 존재합니다. 이러한 SDK 또는 라이브러리를 사용하는 애플리케이션은 LiteRT로 이전해서는 안 됩니다.