ModelInterpreter
class ModelInterpreter : NSObjectA Firebase interpreter for a custom model.
-
Enables stats collection in ML Kit model interpreter. The stats include API call counts, errors, API call durations, options, etc. No personally identifiable information is logged.
The setting is per
FirebaseApp, and therefore perModelInterpreter, and it is persistent across launches of the app. It means if the user uninstalls the app or clears all app data, the setting will be erased. The best practice is to set the flag in each initialization.By default the logging is enabled. You have to specifically set it to false to disable logging.
Declaration
Swift
var isStatsCollectionEnabled: Bool { get set } -
Gets an instance of a custom model interpreter for the given
localModeland the default Firebase app. The default Firebase app instance must be configured before calling this method; otherwise, raisesFIRAppNotConfiguredexception. The returned interpreter is thread safe. Custom models hosted in non-default Firebase apps are currently not supported.Declaration
Swift
class func modelInterpreter(localModel: FIRCustomLocalModel) -> SelfParameters
localModelCustom local model.
Return Value
A custom model interpreter with the given options and the default Firebase app.
-
Gets an instance of a custom model interpreter for the given
remoteModeland the default Firebase app. The default Firebase app instance must be configured before calling this method; otherwise, raisesFIRAppNotConfiguredexception. The returned interpreter is thread safe. Custom models hosted in non-default Firebase apps are currently not supported.It is recommended that the
CustomRemoteModelbe downloaded before creating a new instance ofModelInterpreter. To download the remote model, invoke theModelManager‘sdownload(_:conditions:)method and monitor the returnedProgressand/or listen for the download notifications defined inFIRModelDownloadNotifications.h.Declaration
Swift
class func modelInterpreter(remoteModel: FIRCustomRemoteModel) -> SelfParameters
remoteModelCustom remote model.
Return Value
A custom model interpreter with the given options and the default Firebase app.
-
Unavailable.
-
Runs model inference with the given inputs and data options asynchronously. Inputs and data options should remain unchanged until the model inference completes.
Declaration
Swift
func run(inputs: FIRModelInputs, options: FIRModelInputOutputOptions, completion: @escaping ModelInterpreterRunCallback)Parameters
inputsInputs for custom model inference.
optionsData options for the custom model specifiying input and output data types and dimensions.
completionHandler to call back on the main thread with
ModelOutputsor error. -
Gets the index of an input op with the given name.
Declaration
Swift
func inputIndex(opName: String, completion: @escaping ModelInterpreterInputOutputOpIndexCallback)Parameters
opNameThe name of the input op.
completionHandler to call back on the main thread with input op index as an
unsignedIntValueor error. -
Gets the index of an output op with the given name.
Declaration
Swift
func outputIndex(opName: String, completion: @escaping ModelInterpreterInputOutputOpIndexCallback)Parameters
opNameThe name of the output op.
completionHandler to call back on the main thread with output op index as an
unsignedIntValueor error.