Help us understand the problem. What is going on with this article?

TensorFlow Lite のiOS GPU対応チュートリアルやってみた

画像分類デモの取得と実行

準備

  • Device: iOS 12.0以上
  • Xcode 10.0以上
  • Apple Developer ID
  • Xcode command line tools
xcode-select --install
  • CocoaPods
sudo gem install cocoapods

Build and Run

  • デモのclone
git clone https://github.com/tensorflow/examples.git
  • ワークスペースファイルの生成
cd examples/lite/examples/image_classification/ios
pod update
pod install

これにより、ImageClassification.xcworkspaceが作成される

  • ワークスペースを開く
open ImageClassification.xcworkspace
  • ビルドと実行

1, Xcode 内で、ImageClassificationを選択し、プロジェクト構成を開、[genenral]タブの[Signing]で開発チームを選択
2, Identity section内、そしてすべてのXcodeプロジェクトで一意になるようにBundle Identifierを変更
3,iOSデバイスを接続し、ビルド、実行

TensorFLow Liteの導入

  • Swiftに追加 Podfile内に以下を追加しpod installし直す。
use_frameworks!
pod 'TensorFlowLiteSwift'
  • ライブラリのインポート

SwiftファイルにTensorFlow Liteモジュールをインポート

import TensorFlowLite

TensorFLow Lite GPUの導入

  • Swiftに追加 Podfile内に以下を追加しpod installし直す。
# pod 'TensorFlowLite'
pod 'TensorFlowLiteGpuExperimental'
  • GPU Delegateを有効にする CameraExampleViewController.hにおいて、
#define TFLITE_USE_GPU_DELEGATE 1
  • リリースモードに変更

1, Product > Scheme > Edit Scheme...に進み、Runを選択、InfoタブのBuild ConfigurationDebugからReleaseに変更。Debug executableのチェックを外す。
2, Optionsタブをクリックす、GPU Frame CaptureDisabledMetal API ValidationDisabledに変更。
3, Project navigator -> tflite_camera_example -> PROJECT -> tflite_camera_example -> Build SettingsBuild Active Architecture Only > ReleaseYesに設定

  • ビルドし実行

デバイスを接続しXcodeからビルド、実行

参照

TensorFlow Lite image classification iOS example application
Tensor Flow Lite iOS quickstart
TensorFlow Lite GPU delegate

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away