Mobile

Clarifai’s Apple SDK enables machine learning directly on your device, bypassing the traditional requirement of internet connectivity and extensive computing power. It makes it easy to use image and video recognition on device and in real-time.

Apple SDK

The Apple SDK is currently available. You can get more information on installing the sdk here.

Start the SDK

The Clarifai SDK is initialized by calling the startWithApiKey method. We recommend to start it when your app finishes launching, but that is not absolutely required. And don't worry about hogging the launching of your app. We offload the work to background threads; there should be little to no impact.

js
python
java
csharp
objective-c
php
cURL
// Only for the Apple SDK

Inputs On Device

The SDK is built around a simple idea. You give inputs (images) to the library and it returns predictions (concepts). You need to create inputs to make predictions on them.

The sections below will showcase how to create Inputs from images on your device.

Add Device Inputs

All inputs are created from a DataAsset object in the Apple SDK. A Data Asset is a container for the asset in question, plus metadata related to it. You can create a DataAsset initialized with an Image on Device or from a URL as shown in the example below.

js
python
java
csharp
objective-c
php
cURL
// Only for the Apple SDK

Saving and Loading Inputs

After creating Inputs, it is also possible to save them in the SDK for later use. For example, you may want to store Inputs for further predictions in the future. Below is code that demonstrates how to save an Input and reload it from the SDK.

js
python
java
csharp
objective-c
php
cURL
// Only for the Apple SDK

Prediction On Device

Just as with our API, you can use the predict functionality on device with our Public Models.

Predictions generate outputs. An output has a similar structure to an input. It contains a data asset and concepts. The concepts associated with an output contain the predictions and their respective score (degree of confidence.)

Note that the prediction results from pre-built models on the SDK may differ from those on the API. Specifically, there may be a loss of accuracy up to 5% due to the conversion of the models that allow them to be compact enough to be used on lightweight devices. This loss is expected within the current industry standards.

js
python
java
csharp
objective-c
php
cURL
// Only for the Apple SDK

On Device Public Models

Our team has developed a variety of pre-trained public models which our users can make predictions against. As of now, we have enabled our most comprehensive model, the General Model, to be loaded on device. For access to other models please contact sales@clarifai.com. The sample code below shows how to load the General Model and make a prediction against it.

js
python
java
csharp
objective-c
php
cURL
// Only for the Apple SDK