loadFromBytes method
Loads a TFLite model from raw bytes.
Useful for models downloaded at runtime or bundled differently.
Implementation
Interpreter loadFromBytes(
Uint8List modelBytes, {
String? cacheKey,
int numThreads = 2,
}) {
if (cacheKey != null && _cache.containsKey(cacheKey)) {
return _cache[cacheKey]!;
}
final options = InterpreterOptions()..threads = numThreads;
final interpreter = Interpreter.fromBuffer(
modelBytes,
options: options,
);
if (cacheKey != null) {
_cache[cacheKey] = interpreter;
}
return interpreter;
}