SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Use the Image Classifier API on SAP BTP

Connect to an Image Classifier API with the help of the SAP BTP SDK Assistant for iOS and SAP API Business Hub

Overview

You will learn

  • ✔How to connect to the correct API through the Assistant
  • ✔How access the Image Classifier API to identify images
Kevin Muessig K Kevin Muessig January 9, 2023
Created on January 9, 2023
Contributors

More from Kevin Muessig

See all 13 tutorials by Kevin Muessig →

Prerequisites

Steps

Details

You will learn

  • How to connect to the correct API through the Assistant
  • How access the Image Classifier API to identify images

Step 1 Create a new Xcode project
—

For this tutorial we will create a Xcode project from scratch via Xcode and connect to the API manually. Please go ahead and create a new Xcode Project with the following configuration:

PropertyValue
TemplateSingle View App
Product NameMyImageClassifierApp

For the other properties choose something which match your preferences.

xcode
xcode

Now we want to find the right API for us to classify images with. Fortunately the SAP API Business Hub offers such an API. Please go to SAP API Business Hub and search for SAP Leonardo ML - Functional Services. Click on the SAP Leonardo Machine Learning Foundation - Functional Services to go to the available APIs.

xcode
xcode

We want to use the Product Image Classification API, for that please search for Image. Click on the Product Image Classification API to see the API details.

xcode
xcode

The SAP API Business Hub offers code snippets for the API implementation in several languages like JavaScript, Java, Swift or SAPUI5. Please click on Code Snippet.

xcode
xcode

In the code snippet pop-up, select the language Swift and click on Copy and Close. We have the needed code in the clipboard.

xcode
xcode

A typical 200 response from the API would look like this:

JSON
{
  "_id": "string",
  "error": "string",
  "request": "string",
  "predictions": [
    {
      "name": "string",
      "results": [
        {
          "label": "string",
          "score": 0
        }
      ]
    }
  ],
  "status": "QUEUED",
  "tenantName": "string",
  "error_description": "string"
}
Step 2 Export the needed SAP Frameworks to your Xcode project
+
Step 3 Add a Table View to your app
+
Step 4 Add an Image picker
+
Step 5 Add access to the Camera and Photo Library
+
Step 6 Change the class delegates and add import statements
+
Step 7 Implement logic to use the FUIObjectTableViewCell to display the classifiers result
+
Step 8 Implement logic to use the Camera and Photo Library
+
Step 9 Add a UIImage extension to resize images
+
Step 10 Connect to the SAP Leonardo Image Classification API
+
Step 11 Implement UIImagePickerControllerDelegate
+
Step 12 Run the app and classify some images
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 12
1. Create a new Xcode project 2. Export the needed SAP Frameworks to your Xcode project 3. Add a Table View to your app 4. Add an Image picker 5. Add access to the Camera and Photo Library 6. Change the class delegates and add import statements 7. Implement logic to use the FUIObjectTableViewCell to display the classifiers result 8. Implement logic to use the Camera and Photo Library 9. Add a UIImage extension to resize images 10. Connect to the SAP Leonardo Image Classification API 11. Implement UIImagePickerControllerDelegate 12. Run the app and classify some images