1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CustomVisionでエクスポートしたモデルをAndroidスマホで動かす

Last updated at Posted at 2018-08-26

はじめに

AzureのCustomVisionServiceでは、トレーニングしたモデルをエクスポートすることができます。このモデルをAndroideスマホで動かせるのか試してみましたっというメモです。

モデル作成

詳細は割愛しますが、CustomVisionServiceで画像をアップロードし、ラベルづけを行い、トレーニングしました。
モデルが出来上がったら、「Performance」の「Export」でTF(Android)を選択し、モデルをダウンロードしました。zipファイルの中にラベルが記載されたテキストファイルと拡張子がpbのモデルが入っています。

Azureサンプルを使ってみる

以下の記事を拝見したので、Androidでもてっきり簡単にできるものだと思っていました。

「Custom Vision Serviceを使ってお花判定カメラアプリを作る」
https://blog.nextscape.net/archives/Date/2018/02/customvision_ios

Android用のサンプルはGithub上で見つけました。
https://github.com/Azure-Samples/cognitive-services-android-customvision-sample

これをAndroidStudioで読み込んで、apkファイルを作成し、自分のスマホ(Huawei p20 lite)に入れてみました。

が、起動してすぐに落ちてしまい、うまく動きません。

なんでかなーと色々調べていたところ、まさしくなissueが上がっていました↓
「i am trying to develop android app but the app keeps on crashing #8」
ちょっとコードに手を加えてOK!という感じではないことはわかりました。

Tensorflowデモを使ってみる

というわけで、Azureサンプルを使うのは諦めて、Tensorflowのデモアプリを試してみることにしました。
やり方は以下のページに詳しいので割愛します。
https://www.tensorflow.org/mobile/android_build

こちらは問題なく動かすことができました。

ちなみに、CustomVisionでエクスポートしたモデルをこのデモアプリで使う場合は、ちょっとソースコードをいじる必要があります。
一応動くことは確認できたのですが、もうちょっと調べてから記載しようと思います。

以上

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?