Deep Dive with IBM Watson Visual Recognition

Son Le - IBM Cloud Technical Evangelist

E: sonle@sg.ibm.com

T: @thsonvt

Agenda

  • Introduction
  • How it works
    • API Calls
    • Train a custom image classifier
    • Demo
  • Other similar IBM Bluemix services
  • Q&A

IBM Watson Visual Recognition

* Answering the question: “What is in this image?” 

 

* Automatically annotating images based on visual content alone, processing the pixels of an image

 

* Uses semantic classifiers built with machine-learning technology to recognize visual entities.

 

* The service can learn from images you provide

IBM Watson Visual Recognition - How it works

2 main concepts: Classifier, Score

API Calls

Method Usage
POST /v2/classify Classify an image
GET /v2/classifiers Retrieve a list of classifiers
GET /v2/classifiers/{classifier_id}
 
Retrieve classifier details
POST /v2/classifiers Create a classifier
DELETE /v2/classifiers/{classifier_id} Delete a classifier

POST /v2/classify - Classify an image

POST /v2/classify - Classify an image

curl -u "{username}":"{password}" \
-X POST \
-F "images_file=@test.jpg" \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
{
  "images": [
    {
      "image": "test.jpg",
      "scores": [
        {
          "classifier_id": "sports",
          "name": "Sports",
          "score": 0.700104
        },
        {
          "classifier_id": "cricket_1234",
          "name": "Cricket",
          "score": 0.689532
        }
      ]
    }
  ]
}

POST /v2/classify - Classify an image

* Submit images in batches as compressed (.zip) files

 

* Batches of images are not required to be a specific size

 

* Can send up to six requests at the same time

 

* Specify only the classifiers you want results for in the classifier_ids parameter

 

GET /v2/classifiers - Retrieve a list of classifiers

GET /v2/classifiers - Retrieve a list of classifiers

curl -u "{username}":"{password}" \
-X GET \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers?version=2015-12-02"
{
  "classifiers": [
    {
      "classifier_id": "nightvsday_11138698",
      "name": "night vs day"
    },
    {
      "classifier_id": "tiger_458617357",
      "name": "tiger"
    },
    {
      "classifier_id": "Black",
      "name": "Black"
    },
    {
      "classifier_id": "Blue",
      "name": "Blue"
    }
 ]
}

GET /v2/classifiers/{classifier_id} - Retrieve classifier details

GET /v2/classifiers/{classifier_id} - Retrieve classifier details

curl -u "{username}":"{password}" \
-X GET \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers/tiger_1234?version=2015-12-02"
{
   "name": "tiger",
   "classifier_id": "tiger_1234",
   "created": "2015-03-25T12:00:00",
   "owner": "ss324f-23sf65-sdf321-dfsgh87j"   
}

POST /v2/classifiers - Create a classifier

POST /v2/classifiers - Create a classifier

curl -u "{username}":"{password}" \
-X POST \
-F "positive_examples=@tigers.zip" \
-F "negative_examples=@lions_leopards.zip" \
-F "name=tiger" \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers?version=2015-12-02"
{
  "name": "tiger",
  "classifier_id": "tiger_1234",
  "created": "2015-11-23 17:43:11+00:00",
  "owner": "dkfj32-al543-324js-382js"
}

POST /v2/classifiers - Create a classifier

* Images can be in .jpg, .png, or .gif format

* Max of 10,000 entries (folders and images) or 100 MB accepted

 

* Min of 50 images in each .zip file is recommended

 

* For better results, upload a total of 150-200 images, with an equal number of negative images to positive images.

 

*The positive images and negative images you provide must be different. 

 

* Training a classifier on more images reaches its peak at around 5000 images

POST /v2/classifiers - Create a classifier

DELETE /v2/classifiers/{classifier_id} - Delete a classifier

DELETE /v2/classifiers/{classifier_id} - Delete a classifier

curl -u "{username}":"{password}" \ -X DELETE \ "https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers/tiger_1234?version=2015-12-02"
{}

Error Handling

Error Code Description
200 Success
400 - Bad Request Missing a required parameter, or invalid parameter value
401 - Unauthorized No API key provided, or the API key provided was not valid
404 - Not Found The requested item or parameter doesn't exist.
500 type response Internal system error

Working with Watson Visual Recognition - Some Caveats

* Use images with a resolution of at least 320 by 320 pixels to obtain meaningful results

 

* Classifiers that are provided by the service might change or be removed without notice

 

* The service is not perfect! It might mislabel an image

 

* Custom classifiers created while the Visual Recognition service is in beta will need to be re-created when the service reaches GA.

 

* You cannot update an existing classifier; you can only create new classifiers or delete existing classifiers

Visual Recognition API Reference

Visual Recognition API Explorer

Demo

Bluemix Services Similar to Visual Recognition

AlchemyVision - Automatically extract and tag images

Demo: http://vision.alchemy.ai/

Bluemix Services Similar to Visual Recognition

Visual Insights

Demo: http://visual-insights-demo.mybluemix.net/

http://bit.ly/bluemix28012016-survey

Watson Visual Recognition

By Son Le Thanh

Watson Visual Recognition

  • 1,474