Note: This repo is now being dedicated to my own fun experiments. For a more vanilla version, use the official repo.
Classify images offline with Watson Visual Recognition and Core ML.
A deep neural network model is trained on the cloud by Watson Visual Recognition. The app then downloads the model which can be used offline by Core ML to classify images. Everytime the app is opened it checks if there are any updates to the model and downloads them if it can.
Make sure you have these software versions installed on your machine. These versions are required to support Core ML:
- MacOS 10.11 El Capitan or later
- iOS 11 or later (on your iPhone or iPad if you want the application to be on your device)
- Xcode 9 or later
- Carthage 0.29 or later
Carthage installation
If you don’t have Homebrew on your computer, it’s easier to setup Carthage with the
.pkg
installer. You can download it here.
Use GitHub to clone the repository locally, or download the .zip file of the repository and extract the files.
- Log in to Watson Studio (dataplatform.ibm.com). From this link you can create an IBM Cloud account, sign up for Watson Studio, or log in.
For an in depth walkthrough of creating a custom model, check out the Core ML & Watson Visual Recognition Code Pattern.
The Watson Swift SDK makes it easy to keep track of your custom Core ML models and to download your custom classifiers from IBM Cloud to your device.
Use the Carthage dependency manager to download and build the Watson Swift SDK.
-
Open a terminal window and navigate to this project's directory.
-
Run the following command to download and build the Watson Swift SDK:
carthage update --platform iOS
- Open the project in XCode.
- Copy the Model ID of the model you trained and paste it into the
modelId
property in theCameraViewController.swift
file. - Copy your "apikey" from your Visual Recognition service credentials and paste it into the
apiKey
property in theCredentials.plist
file.
- In Xcode, select the
Core ML Vision
scheme. - You can run the app in the simulator or on your device.
Note: The visual recognition classifier status must be Ready to use it. Check the classifier status in Watson Studio on the Visual Recognition instance overview page.
Try using your own data: Train a Visual Recognition classifier with your own images. For details on the Visual Recognition service, see the links in the Resources section.