Analyzing images using Visual Recognition built-in models

IBM Watson Visual Recognition comes with built-in models that you can use to analyze images for scenes, objects, and many other categories without any training.



Watch this video to see how to use the built-in visual recognition models.

Python notebook example

Here is an example of Python code that uses Visual Recognition built-in models to analyze a sample image. This sample code calls the Visual Recognition API external link and can be run in a notebook in IBM Watson Studio.

!pip install --upgrade "watson-developer-cloud>=1.0,<2.0"
from watson_developer_cloud import VisualRecognitionV3
visual_recognition = VisualRecognitionV3( '2016-05-20', api_key='<your-API-key>' )
image_url = ''
import json
parms = json.dumps( { 'url' : image_url, 'classifier_ids' : [ 'food' ] } )
results = visual_recognition.classify( parameters = parms )
print( json.dumps( results['images'][0]['classifiers'][0]['classes'], indent=2 ) )

For information about how to look up your API key, see: Building Visual Recognition apps.

Sample image

Image of a fruit basket

Sample output

    "class": "lemon",
    "score": 0.583,
    "type_hierarchy": "/fruit/citrus/lemon"
    "class": "citrus",
    "score": 0.719
    "class": "fruit",
    "score": 0.901
    "class": "apple",
    "score": 0.526,
    "type_hierarchy": "/fruit/accessory fruit/apple"
    "class": "accessory fruit",
    "score": 0.526
    "class": "orange",
    "score": 0.518,
    "type_hierarchy": "/fruit/citrus/orange"
    "class": "banana",
    "score": 0.5,
    "type_hierarchy": "/fruit/banana"


See also