Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java program to consume SAP Leonardo machine learning API

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to use the Java program to consume SAP Leonardo machine learning API. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

To develop a Java program, the user can specify a picture. The Java program calls the machine learning API trained on the SAP Leonardo. The API will recognize the picture and return a text message to the user to tell the user the recognition result.

SAP Leonardo Machine Learning-Functional Services

Next we need to use the Java program to call API.

You can see that the SDK is a Gradle-based Java project. You need to download Maven and Gradle and complete the configuration of environment variables, which are very basic and have a lot of information online, so I won't repeat them here.

After the configuration is completed, use the import function of Eclipse to import SDK into Eclipse.

After the import is completed, it is shown in the picture. The red area is the code included with SDK, and the blue area is the code created manually by Jerry itself, which is used to call API and print the result.

Double-click pom.xml in the root directory to maintain the following dependencies:

Error analysis

Going back to the API console, the type of the request field in the API response structure is declared as string.

However, through the test, it is found that the content of the request field is actually a Json object:

Knowing the root of the problem, it will be easy to change it. Create a new Gson container class Request.java, and then maintain the corresponding member variables for Request.java according to the structure of the request field observed in the console.

For example, tenantName is a String in the API response structure, so the type in the Java class is String;files is an array in the API response structure, so the type in the Java class is List.

After the adjustment is completed and executed again, you can see the desired output: call API through SDK and print the result.

This is the end of this article on "how to use Java programs to consume SAP Leonardo machine learning API". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report