Since SAP Leonardo Machine Learning Functional Service are implemented as REST API, the same can be called from ABAP environment too. This blog post will explain the same.
Before I go into details of the implementation let me explain the use case.
We will be building a simple ABAP application to ask user for an image input and pass it to REST API using class CL_REST_HTTP_CLIENT. The Image Classification Service API will return us the classification of images with probabilities.
In my program I tested it using different types of images and the results were quite accurate.
Input to ABAP program
It can bee seen the Machine Learning API was able to predict the image with good accuracy.
Now coming to the actual steps to implement the same
Step1:Get the API key
Go to below URL and get your API key. You will have to register to get the API ket
DATA(lo_post_file) = NEW cl_rest_multipart_form_data( lo_request ).
* send Image file to API
lo_post_file->set_file( iv_name = 'files' "This is the name of fied which API expects: See API documentation
iv_filename = lv_file_name
iv_type = 'image/jpeg'
iv_data = lv_file_content ).