Home

Awesome

Adobe AIR + CoreML

CoreML Adobe Air Native Extension for OSX 10.13+, iOS 11.0+ and tvOS 11.0+ This ANE provides access to Apple's CoreML framework for building Machine Learning apps

ASDocs Documentation


Much time, skill and effort has gone into this. Help support the project

paypal


macOS

The ANE + Dependencies

From the command line cd into /example-desktop and run:

bash get_dependencies.sh

iOS

The ANE + Dependencies

N.B. You must use a Mac to build an iOS app using this ANE. Windows is NOT supported.

From the command line cd into /example-mobile and run:

bash get_ios_dependencies.sh

This folder, ios_dependencies/device/Frameworks, must be packaged as part of your app when creating the ipa. How this is done will depend on the IDE you are using. After the ipa is created unzip it and confirm there is a "Frameworks" folder in the root of the .app package.

tvOS

The ANE + Dependencies

N.B. You must use a Mac to build an tvOS app using this ANE. Windows is NOT supported.

From the command line cd into /example-tvos and run:

bash get_tvos_dependencies.sh

This folder, tvos_dependencies/device/Frameworks, must be packaged as part of your app when creating the ipa. How this is done will depend on the IDE you are using. After the ipa is created unzip it and confirm there is a "Frameworks" folder in the root of the .app package.

Getting Started

Firstly, familiarise yourself with the concepts of Apple's CoreML.

Usage

Check CoreML is supported

coreml = MLANE.coreml;
if (coreml.isSupported) {

} else {

}

Download Model from url and compile

var mobileNetUrl:String = "https://docs-assets.developer.apple.com/coreml/models/MobileNet.mlmodel"
var model:Model = Model.fromUrl(mobileNetUrl, onDownloadProgress, onDownloadComplete, onModelCompiled);
private function onDownloadProgress(event:ProgressEvent):void {
//
}
private function onDownloadComplete(event:Event):void {
//
}
private function onModelCompiled(event:ModelEvent):void {
    model.load();
}

load Model from storage directory and compile

var model:Model = Model.fromPath(File.applicationStorageDirectory.resolvePath("MobileNet.mlmodel").nativePath, onCompiled);
private function onModelCompiled(event:ModelEvent):void {
    model.load();
}

perform prediction with bitmapData as input

var testImage:Bitmap = new TestImage() as Bitmap;
var mobileNet:MobileNet = new MobileNet(testImage.bitmapData);
    model.prediction(mobileNet, onMobileNetResult);
}

Prerequisites

You will need:

Task List

References