Skip to Content

Image services with the API Business Hub console

test
0 %
Image services with the API Business Hub console
Details
// Explore More Tutorials

Image services with the API Business Hub console

12/06/2018

Discover how to test SAP Leonardo Machine Learning Foundation service on the SAP API Business Hub

You will learn

  • Where to find and test the SAP Leonardo Machine Learning Functional Services published on the SAP API Business Hub that consumes images content

This service allows you to calculates and returns a list of classifications/labels along with their probabilities for a given image.

The Image Classification Machine Learning Functional Services will be used as an example to demonstrate how to consume image content, but you will be able to transpose this tutorial to other services which also consume images content like :

Step 1: Search the SAP API Business Hub

In order to consume the Image Classifier Service SAP Leonardo Machine Learning Foundation service, you will first need to get the service URI, request and response parameters.

Go to https://api.sap.com/.

SAP API Business Hub

Then you will be able to search for the SAP Leonardo Machine Learning - Functional Services, then click on the package found.

SAP API Business Hub

Select Inference Service for Customizable Image Classification.

SAP API Business Hub

You can also access the page directly from the following address:

Log on to answer question
Step 2: Analyze the service

As you can notice the API has only one resource (or service): /classification.

Now click on the /classification link to expand the section.

Note: the term inference refers to the application phase (scoring) an existing model (as opposed to the training or inception phase) and sync for synchronous.

As stated in the description, the service accepts either:

  • an archive file with a zip/tar extensions containing multiple image files
  • a single image
  • a list of image as input

The service returns a classification list with its scores (confidence).

The supported image formats are JPEG, PNG, TIF or BMP (the actual content format is validated, so renaming files may simply not work).

The input file, files or archive file will be sent as a FormData query parameter in the service request.

Log on to answer question
Step 3: Test the service

In the top right corner of the page, click on the Log On button.

You will be prompted for your SAP credentials (you can use your SAP Cloud Platform credentials for example).

Scroll down to the Parameters section and click on the Try out button, then you can use the Choose File button next to files parameter to select your files.

Select any image file on your local machine (and if you are missing some inspiration, use Google Search to search for duck images).

Make sure you pick a JPEG, PNG, TIF or BMP format with a resolution below 1024 by 1024 pixels else you will receive a 400 error response.

Now, scroll down and click on Execute.

API Hub

In the Response Body, you will get the top 5 classes/label with an associated score (that sums up to 1).

{
  "_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "predictions": [
    {
      "name": "Duck.jpeg",
      "results": [
        {
          "label": "drake",
          "score": 0.999675
        },
        {
          "label": "goose",
          "score": 0.000313
        },
        {
          "label": "European gallinule",
          "score": 0.000004
        },
        {
          "label": "toucan",
          "score": 0.000003
        },
        {
          "label": "red-breasted merganser",
          "score": 0.000002
        }
      ]
    }
  ],
  "processed_time": "Mon, 31 Jul 2017 13:03:29 GMT",
  "request": {
    "files": [
      "Duck.jpeg"
    ],
    "options": {},
    "tenantName": "imgclassif-tech-user",
    "texts": []
  },
  "status": "DONE",
  "tenantName": "imgclassif-tech-user"
}
Log on to answer question
Step 4: Validation

Provide an answer to the question below then click on Validate.

Based on the provided documentation, which file archive format are supported by the service from the
following list?
×

Optional

Step 5: Investigate similar services

You can also try the following Machine Learning Functional Services consuming images:

Alternatively, you can try to compress into a zip a series of images and call the service.

For more information, you can also check the online SAP Leonardo Machine Learning Foundation documentation

Log on to answer question

Next Steps

Back to top