• This repository has been archived on 30/Jun/2020
  • Stars
    star
    487
  • Rank 86,951 (Top 2 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Classify images offline using Watson Visual Recognition and Core ML

Read this in other languages: 中文, 日本.

Visual Recognition with Core ML

Classify images with Watson Visual Recognition and Core ML. The images are classified offline using a deep neural network that is trained by Visual Recognition.

This project includes the QuickstartWorkspace.xcworkspace workspace with two projects:

  • Core ML Vision Simple: Classify images locally with Visual Recognition.
  • Core ML Vision Custom: Train a custom Visual Recognition model for more specialized classification.

Before you begin

Make sure that you have installed Xcode 10 or later and iOS 11.0 or later. These versions are required to support Core ML.

Getting the files

Use GitHub to clone the repository locally, or download the .zip file of the repository and extract the files.

Running Core ML Vision Simple

Identify common objects with a built-in Visual Recognition model. Images are classified with the Core ML framework.

  1. Open QuickstartWorkspace.xcworkspace in Xcode.
  2. Select the Core ML Vision Simple scheme.
  3. Run the application in the simulator or on your device.
  4. Classify an image by clicking the camera icon and selecting a photo from your photo library. To add a custom image in the simulator, drag the image from the Finder to the simulator window.

Tip: This project also includes a Core ML model to classify trees and fungi. You can switch between the two included Core ML models by uncommenting the model you would like to use in ImageClassificationViewController.

Source code for ImageClassificationViewController.

Running Core ML Vision Custom

The second part of this project builds from the first part and trains a Visual Recognition model (also called a classifier) to identify common types of cables (HDMI, USB, etc.). Use the Watson Swift SDK to download, manage, and execute the trained model. By using the Watson Swift SDK, you don't have to learn about the underlying Core ML framework.

Setting up Visual Recognition in Watson Studio

  1. Log into Watson Studio. From this link you can create an IBM Cloud account, sign up for Watson Studio, or log in.

  2. After you sign up or log in, you'll be on the Visual Recognition instance overview page in Watson Studio.

    Tip: If you lose your way in any of the following steps, click the IBM Watson logo on the top left of the page to bring you to the the Watson Studio home page. From there you can access your Visual Recognition instance by clicking the Launch tool button next to the service under "Watson services".

Training the model

  1. In Watson Studio on the Visual Recognition instance overview page, click Create Model in the Custom box.

  2. If a project is not yet associated with the Visual Recognition instance you created, a project is created. Name your project Custom Core ML and click Create.

    Tip: If no storage is defined, click refresh.

  3. Navigate to the Assets tab and upload each .zip file of sample images from the Training Images directory onto the data pane on the right side of the page. Add the hdmi_male.zip file to your model by clicking the Browse button in the data pane. Also add the usb_male.zip, thunderbolt_male.zip, and vga_male.zip files to your model.

  4. After the files are uploaded, select Add to model from the menu next to each file, and then click Train Model.

Copy your Model ID and API Key

  1. In Watson Studio on the custom model overview page, click your Visual Recognition instance name (it's next to Associated Service).

  2. Scroll down to find the Custom Core ML classifier you just created.

  3. Copy the Model ID of the classifier.

  4. In the Visual Recognition instance overview page in Watson Studio, click the Credentials tab, and then click View credentials. Copy the api_key or the apikey of the service.

    Important: Instantiation with api_key works only with Visual Recognition service instances created before May 23, 2018. Visual Recognition instances created after May 22 use IAM.

Adding the classifierId and apiKey to the project

  1. Open the project in XCode.
  2. Copy the Model ID and paste it into the classifierID property in the ImageClassificationViewController file.
  3. Copy either your api_key or apikey and paste it into either the api_key or apikey property in the ImageClassificationViewController file.

Downloading the Watson Swift SDK

Use the Cocoapods dependency manager to download and build the Watson Swift SDK. The Watson Swift SDK can also be installed via Carthage and Swift Package Manager.

  1. Install Cocoapods.

  2. Open a terminal window and navigate to the Core ML Vision Custom directory.

  3. Run the following command to download and build the Watson Swift SDK:

    pod install

Tip: Regularly download updates of the SDK so you stay in sync with any updates to this project. If you have updated to a new version, you may need to run pod repo update before installing.

Testing the custom model

  1. Open QuickstartWorkspace.xcworkspace in Xcode.

  2. Select the Core ML Vision Custom scheme.

  3. Run the application in the simulator or on a device.

  4. Classify an image by clicking the camera icon and selecting a photo from your photo library. To add a custom image in the simulator, drag the image from the Finder to the simulator window.

  5. Pull new versions of the visual recognition model with the refresh button in the bottom right.

    Tip: The classifier status must be Ready to use it. Check the classifier status in Watson Studio on the Visual Recognition instance overview page.

Source code for ImageClassificationViewController.

What to do next

Add another Watson service to the custom project with the Core ML Visual Recognition with Discovery project.

Resources

More Repositories

1

node-sdk

☄️ Node.js library to access IBM Watson services.
TypeScript
1,482
star
2

python-sdk

🐍 Client library to use the IBM Watson services in Python and available in pip as watson-developer-cloud
Python
1,452
star
3

speech-to-text-nodejs

🎤 Sample Node.js Application for the IBM Watson Speech to Text Service
JavaScript
1,086
star
4

swift-sdk

📱 The Watson Swift SDK enables developers to quickly add Watson Cognitive Computing services to their Swift applications.
Swift
880
star
5

java-sdk

🥇 Java SDK to use the IBM Watson services.
Java
586
star
6

unity-sdk

🎮 Unity SDK to use the IBM Watson services.
C#
570
star
7

personality-insights-nodejs

📊 Sample Nodejs Application for the IBM Watson Personality Insights Service
JavaScript
558
star
8

assistant-simple

A simple sample application demonstrating the Watson Assistant api.
JavaScript
482
star
9

tone-analyzer-nodejs

Sample Node.js Application for the IBM Tone Analyzer Service
CSS
452
star
10

text-to-speech-nodejs

This is a deprecated Watson Text to Speech Service Demo. A link to the newly supported demo is below
JavaScript
346
star
11

speech-javascript-sdk

Library for using the IBM Watson Speech to Text and Text to Speech services in web browsers.
JavaScript
256
star
12

node-red-labs

Node-RED labs on the use of the Watson Developer Cloud services
208
star
13

botkit-middleware

A middleware to connect Watson Conversation Service to different chat channels using Botkit
TypeScript
208
star
14

natural-language-classifier-nodejs

Deprecated: this demo will receive no further updates
JavaScript
158
star
15

dotnet-standard-sdk

🆕🆕🆕.NET Standard library to access Watson Services.
C#
146
star
16

android-sdk

🔆 Android SDK to use the IBM Watson services.
Java
145
star
17

assistant-with-discovery

DEPRECATED: this application is deprecated and thus will not receive fixes or security updates. It is archived for educational purposes, but may not function.
Java
145
star
18

natural-language-understanding-nodejs

🆕 Demo code for the Natural Language Understanding Service.
JavaScript
133
star
19

api-guidelines

👮 REST API guidelines created for the Watson Developer Cloud services
133
star
20

assistant-toolkit

Toolkit for experimentation with watsonx Assistant
HTML
100
star
21

car-dashboard

Application that demonstrates how the Watson Assistant service uses intent capabilities in an animated car dashboard UI.
JavaScript
91
star
22

node-red-node-watson

A collection of nodes for the IBM Watson services
HTML
83
star
23

discovery-nodejs

This is a deprecated Watson Discovery Service Demo. A link to the newly supported demo is below
JavaScript
76
star
24

go-sdk

🐭 go SDK for the IBM Watson services.
Go
71
star
25

assistant-improve-recommendations-notebook

Assistant Improve notebooks for Watson Assistant
Jupyter Notebook
68
star
26

investment-advisor

DEPRECATED: this repo is no longer actively maintained
JavaScript
66
star
27

speech-android-sdk

DEPRECATED - Please use https://github.com/watson-developer-cloud/android-sdk
Java
66
star
28

dialog-tool

DEPRECATED: this repo is no longer actively maintained
CSS
60
star
29

doc-tutorial-downloads

The download files from the IBM Watson Service documentation tutorials
Shell
55
star
30

language-translator-nodejs

Sample Node.js Application for the IBM Language Translator Service
CSS
51
star
31

sentiment-and-emotion

DEPRECATED: this repo is no longer actively maintained
CSS
50
star
32

simple-chat-swift

DEPRECATED: this repo is no longer actively maintained
Swift
48
star
33

ruby-sdk

♦️ Ruby SDK to use the IBM Watson services.
Ruby
45
star
34

raspberry-pi-speech-to-text

DEPRECATED: this repo is no longer actively maintained
JavaScript
44
star
35

food-coach

DEPRECATED: this repo is no longer actively maintained
JavaScript
39
star
36

assistant-skill-analysis

Dialog Skill Analysis framework for Watson Assistant
Jupyter Notebook
39
star
37

community

Example data that can be used for various Watson services
Shell
34
star
38

speech-to-text-swift

Speech-to-Text example using the Swift SDK
Swift
34
star
39

visual-recognition-code-pattern

JavaScript
33
star
40

react-components

DEPRECATED: this repo is no longer actively maintained
JavaScript
31
star
41

assistant-dialog-flow-analysis

Dialog Flow Analysis Notebook for Watson Assistant
HTML
28
star
42

salesforce-sdk

A Salesforce library for communicating with the IBM Watson REST APIs
Apex
28
star
43

conversation-connector

The Conversation connector is a set of components that mediate communication between your Conversation workspace and a Slack or Facebook app. Use the connector to deploy a chat bot that Slack or Facebook Messenger users can interact with.
JavaScript
27
star
44

document-conversion-nodejs

DEPRECATED: Please use https://github.com/watson-developer-cloud/discovery-nodejs
JavaScript
27
star
45

text-to-speech-java

DEPRECATED: this repo is no longer actively maintained
CSS
27
star
46

assistant-web-chat-service-desk-starter

A starter kit for building custom service desk integrations for Watson Assistant web chat
TypeScript
25
star
47

raspberry-pi-time-weather-demo

DEPRECATED: this repo is no longer actively maintained
JavaScript
24
star
48

assistant-demo

Assistant demo
JavaScript
23
star
49

discovery-starter-kit

IBM Watson Discovery Starter Kit
JavaScript
22
star
50

assistant-intermediate

An intermediate example of Watson Assistant in a Node.js application
JavaScript
22
star
51

discovery-components

IBM Watson Discovery components
TypeScript
22
star
52

assistant-with-discovery-openwhisk

DEPRECATED: this repo is no longer actively maintained
CSS
21
star
53

company-insights

DEPRECATED: this repo is no longer actively maintained
JavaScript
20
star
54

text-to-speech-swift

DEPRECATED: this repo is no longer actively maintained
Swift
20
star
55

speech-to-text-websockets-ruby

Ruby client that interacts with the IBM Watson Speech to Text service through its WebSockets interface
Ruby
19
star
56

social-customer-care

DEPRECATED: this repo is no longer actively maintained
CSS
19
star
57

customer-engagement-bot

DEPRECATED: this repo is no longer actively maintained
JavaScript
18
star
58

abap-sdk-nwas

ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit
ABAP
18
star
59

assistant-web-chat

Language strings for web chat integration of IBM watsonx assistant
JavaScript
16
star
60

python-primer-companion-code

DEPRECATED: this repo is no longer actively maintained
Python
15
star
61

spring-boot-starter

Spring Boot support for Watson services
Java
13
star
62

personality-insights-java

DEPRECATED: this repo is no longer actively maintained
CSS
13
star
63

watson-developer-cloud.github.io

Index page with links to SDKs, docs, etc.
HTML
13
star
64

simple-chat-objective-c

DEPRECATED: this repo is no longer actively maintained
Objective-C
12
star
65

ui-components

DEPRECATED: this repo is no longer actively maintained
CSS
12
star
66

openwhisk-sdk

🆕 SDK for using Watson Services on IBM Cloud Functions (based on Apache Openwhisk) - DEPRECATED
JavaScript
12
star
67

text-bot-openwhisk

DEPRECATED: this repo is no longer actively maintained
JavaScript
12
star
68

app-insights-discovery

DEPRECATED: this repo is no longer actively maintained
Swift
10
star
69

customer-engagement-nodejs

Customer Engagement
JavaScript
10
star
70

token-generator

Basic Node.js Server to generate watson auth tokens from user-supplied credentials.
JavaScript
6
star
71

watson-vision-coreml-code-pattern

Watson Visual Recognition CoreML Code Pattern
CSS
5
star
72

abap-sdk-scp

ABAP code for using IBM Watson Developer Services with SAP Cloud Platform, imported via abapGit with dependencies via APACK
ABAP
5
star
73

restkit

Core networking and authentication library for the Watson Swift SDK
Swift
4
star
74

cognitive-client-java

DEPRECATED: this repo is no longer actively maintained
Java
4
star
75

speech-to-text-utils

Speech to text CLI that helps you manage speech customizations.
JavaScript
4
star
76

homebrew-tools

DEPRECATED: this repo is no longer actively maintained
Ruby
3
star
77

language-translator-tooling

DEPRECATED: this repo is no longer actively maintained
JavaScript
2
star
78

discovery-nodejs-static

Sample Node.js application that uses the IBM Watson Discovery Service
JavaScript
2
star
79

natural-language-classifier-intent-classification-demo

Deprecated
JavaScript
2
star
80

natural-language-understanding-code-pattern

Natural Language Understanding Code Pattern
JavaScript
2
star
81

speech-to-text-code-pattern

React app using the Watson Speech to Text service to transform voice audio into written text.
JavaScript
2
star
82

swift-playgrounds

Swift playgrounds for Watson Developer Cloud services
Swift
2
star
83

actions-logging-server

HTML
1
star
84

sdk-example-editor

Web application that helps edit SDK examples from an OpenAPI file.
JavaScript
1
star
85

Watson-Assistant-Workspace-Retrain

Python
1
star
86

actions-analytics-dashboard

JavaScript
1
star
87

assistant-web-chat-react

A React library to make integration of Watson Assistant web chat with a React application easy.
TypeScript
1
star
88

visual-recognition-utils

Command line tools to make creating & managing Watson Visual Recognition Custom Classifiers easier.
JavaScript
1
star