Package apple.coreml

Class MLModel

  • All Implemented Interfaces:
    NSObject

    public class MLModel
    extends NSObject
    MLModel Construct a model and evaluate on a specific set of input features. Inputs and outputs are accessed via the MLFeatureProvider protocol. Returns a model or nil if there is an error. API-Since: 11.0
    • Constructor Detail

      • MLModel

        protected MLModel​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • alloc

        public static MLModel alloc()
      • allocWithZone

        public static MLModel allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
      • compileModelAtURLError

        @Nullable
        @Deprecated
        public static @Nullable NSURL compileModelAtURLError​(@NotNull
                                                             @NotNull NSURL modelURL,
                                                             @Nullable
                                                             @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Deprecated.
        Compile a .mlmodel for this device [@returns] a URL to the compiled .mlmodelc directory if successful The model is compiled to a temporary location on disk You must move the compiled model to a permanent location if you wish to keep it The returned model can be loaded using: [@code] [MLModel modelWithContentsOfURL:error:] [@endcode] API-Since: 11.0 Deprecated-Since: 100000.0 Deprecated-Message: Use the asynchronous interface compileModelAtURL:completionHandler:error: instead.
        Parameters:
        modelURL - URL file path to .mlmodel file you wish to compile
        error - Any errors are surfaced here
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • modelDescription

        @NotNull
        public @NotNull MLModelDescription modelDescription()
        A model holds a description of its required inputs and expected outputs.
      • modelWithContentsOfURLError

        public static MLModel modelWithContentsOfURLError​(@NotNull
                                                          @NotNull NSURL url,
                                                          @Nullable
                                                          @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Construct a model with a default MLModelConfiguration object
      • new_objc

        public static MLModel new_objc()
      • predictionFromFeaturesError

        @Nullable
        public @Nullable MLFeatureProvider predictionFromFeaturesError​(@NotNull
                                                                       @NotNull MLFeatureProvider input,
                                                                       @Nullable
                                                                       @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Convenience method to run a prediction synchronously with default prediction options.
      • predictionFromFeaturesOptionsError

        @Nullable
        public @Nullable MLFeatureProvider predictionFromFeaturesOptionsError​(@NotNull
                                                                              @NotNull MLFeatureProvider input,
                                                                              @NotNull
                                                                              @NotNull MLPredictionOptions options,
                                                                              @Nullable
                                                                              @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Run a prediction on a model synchronously [@returns] The output features from the prediction
        Parameters:
        input - The input features to make a prediction from
        options - Prediction options to modify how the prediction is run
        error - The out parameter for error when nil is returned. On success, it is nil
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • version_static

        public static long version_static()
      • configuration

        @NotNull
        public @NotNull MLModelConfiguration configuration()
        The load-time parameters used to instantiate this MLModel object. API-Since: 12.0
      • modelWithContentsOfURLConfigurationError

        public static MLModel modelWithContentsOfURLConfigurationError​(@NotNull
                                                                       @NotNull NSURL url,
                                                                       @NotNull
                                                                       @NotNull MLModelConfiguration configuration,
                                                                       @Nullable
                                                                       @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Construct a model given the location of its on-disk representation. Returns nil on error. API-Since: 12.0
      • parameterValueForKeyError

        @Nullable
        public @Nullable java.lang.Object parameterValueForKeyError​(@NotNull
                                                                    @NotNull MLParameterKey key,
                                                                    @Nullable
                                                                    @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Provides value for the given parameter. Returns nil on error. API-Since: 13.0
      • predictionsFromBatchError

        @Nullable
        public @Nullable MLBatchProvider predictionsFromBatchError​(@NotNull
                                                                   @NotNull MLBatchProvider inputBatch,
                                                                   @Nullable
                                                                   @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Batch prediction without explicit options API-Since: 12.0
      • predictionsFromBatchOptionsError

        @Nullable
        public @Nullable MLBatchProvider predictionsFromBatchOptionsError​(@NotNull
                                                                          @NotNull MLBatchProvider inputBatch,
                                                                          @NotNull
                                                                          @NotNull MLPredictionOptions options,
                                                                          @Nullable
                                                                          @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Batch prediction with explicit options API-Since: 12.0
      • loadContentsOfURLConfigurationCompletionHandler

        public static void loadContentsOfURLConfigurationCompletionHandler​(@NotNull
                                                                           @NotNull NSURL url,
                                                                           @NotNull
                                                                           @NotNull MLModelConfiguration configuration,
                                                                           @NotNull
                                                                           @NotNull MLModel.Block_loadContentsOfURLConfigurationCompletionHandler handler)
        Construct a model asynchronously given the location of its on-disk representation and configuration. Model loading may take time when the model content is not immediately available (e.g. encrypted model). Use this factory method especially when the caller is on the main thread.
        Parameters:
        url - the location of its on-disk representation (.mlmodelc directory).
        configuration - The model configuration
        handler - When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid MLModel instance or NSError object. API-Since: 14.0
      • compileModelAtURLCompletionHandler

        public static void compileModelAtURLCompletionHandler​(@NotNull
                                                              @NotNull NSURL modelURL,
                                                              @NotNull
                                                              @NotNull MLModel.Block_compileModelAtURLCompletionHandler handler)
        Compile a .mlmodel or .mlpackage for this device. Perform the compilation asynchronously. The model is compiled to a temporary location in the file system. You must move the compiled model to a permanent location if you wish to keep it. Then the model can be loaded using the returned URL: [@code] [MLModel modelWithContentsOfURL:error:] [@endcode] API-Since: 16.0
        Parameters:
        modelURL - URL file path to .mlmodel file you wish to compile
        handler - When the model compilation completes successfully the completion handler is invoked with a valid URL to the compiled .mlmodelc directory. On failure, signified by nil compiledModelURL, the NSError object is populated.
      • loadModelAssetConfigurationCompletionHandler

        public static void loadModelAssetConfigurationCompletionHandler​(@NotNull
                                                                        @NotNull MLModelAsset asset,
                                                                        @NotNull
                                                                        @NotNull MLModelConfiguration configuration,
                                                                        @NotNull
                                                                        @NotNull MLModel.Block_loadModelAssetConfigurationCompletionHandler handler)
        Construct a model asynchronously from a compiled model asset.
        Parameters:
        asset - Compiled model asset derived from in-memory or on-disk Core ML model
        configuration - Model configuration that hold options for loading a model
        handler - When the model load completes successfully or unsuccessfully, the completion handler is invoked with a valid MLModel instance or NSError object. API-Since: 16.0
      • availableComputeDevices

        @NotNull
        public static @NotNull NSArray<?> availableComputeDevices()
        The list of available compute devices for CoreML. Use the method to get the list of compute devices that MLModel's prediction can use. Some compute devices on the hardware are exclusive to the domain ML frameworks such as Vision and SoundAnalysis and not available to CoreML. See also `MLComputeDevice.allComputeDevices`. API-Since: 17.0
      • predictionFromFeaturesOptionsCompletionHandler

        public void predictionFromFeaturesOptionsCompletionHandler​(@NotNull
                                                                   @NotNull MLFeatureProvider input,
                                                                   @NotNull
                                                                   @NotNull MLPredictionOptions options,
                                                                   @NotNull
                                                                   @NotNull MLModel.Block_predictionFromFeaturesOptionsCompletionHandler completionHandler)
        Run a prediction on a model asynchronously.
        Parameters:
        input - The input features to make a prediction from
        options - Prediction options to modify how the prediction is run
        completionHandler - A block that will be invoked once the prediction has completed successfully or unsuccessfully. On success, it is invoked with a valid model output. On failure, it is invoked with a nil output and NSError API-Since: 17.0
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.