これ記事によると、TensorFlow LiteでGPUが利用できるみたい。
パブリックなモデルとして、以下の4つがダウンロード可能
・MobileNet v1 (224x224) image classification [download] (image classification model designed for mobile and embedded based vision applications) ・PoseNet for pose estimation [download] (vision model that estimates the poses of a person(s) in image or video) ・DeepLab segmentation (257x257) [download] (image segmentation model that assigns semantic labels (e.g., dog, cat, car) to every pixel in the input image) ・MobileNet SSD object detection [download] (image classification model that detects multiple objects with bounding boxes)
また、Googleオリジナルのモデルとして、次の2つもダウンロード可能
・Face contours as used by MLKit ・Realtime Video Segmentation as used by Playground Stickers and YouTube Stories
AndroidのJavaのサンプルコード
引用します // Initialize interpreter with GPU delegate. GpuDelegate delegate = new GpuDelegate(); Interpreter.Options options = (new Interpreter.Options()).addDelegate(delegate); Interpreter interpreter = new Interpreter(model, options); // Run inference. while (true) { writeToInputTensor(inputTensor); interpreter.run(inputTensor, outputTensor); readFromOutputTensor(outputTensor); } // Clean up. delegate.close();
のInterpreterのaddDelegateって、ここですよ
/** * Adds a {@link Delegate} to be applied during interpreter creation. * * <p>WARNING: This is an experimental interface that is subject to change. */ public Options addDelegate(Delegate delegate) { delegates.add(delegate); return this;
Delegateを変えるだけだからね。