Create a MATLAB® function that can perform inference using the object
net. This function loads the Mobilenet-V1 model into a persistent
network object. Then the function performs prediction by passing the network object to
the predict function. Subsequent calls to this function reuse this the persistent
object.
function out = tflite_predict(in)
persistent net;
if isempty(net)
net = loadTFLiteModel('mobilenet_v1_0.5_224.tflite');
end
out = predict(net,in);
end
net — Object representing TensorFlow Lite model TFLiteModel object
TFLiteModel object that represents the TensorFlow Lite model file.
X — Input to the network numeric array
Image or sequence input to the network, specified as a numeric array.
For image classification networks, the input must be of shape (H,W,C,N), where H
is height, W is width, C is channel, and N is batch size.
For recurrent neural networks, the input must be of shape (D, N, S), where D is
channel or feature dimension, N is batch size, and S is timestamp or sequence
length.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.