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 retrain the machine learning model on SAP Leonardo

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

Share

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

This article mainly introduces "how to retrain the machine learning model on SAP Leonardo". In daily operation, I believe many people have doubts about how to retrain the machine learning model on SAP Leonardo. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to retrain the machine learning model on SAP Leonardo". Next, please follow the editor to study!

How to consume SAP Leonardo in Web applications how to consume API applications deployed in SAP Cloud Platform CloudFoundry environment

At the time, Jerry mentioned that Product Image Classification API supported only 29 product categories:

If we need to support additional product categories when developing applications, we need to provide our own pictures of that product category and retrain it.

Here are the retraining steps for the machine learning model on SAP Leonardo.

Assuming that we expect the Product Image Classfication model to identify different kinds of flowers after retraining, we first have to get a large number of pictures of flowers. On Tensorflow's website, learners who want to do model training have been provided with a compressed package for exercises, which contains a large number of pictures of all kinds of flowers. Http://download.tensorflow.org/example_images/flower_photos.tgz

The dataset accepted by SAP Leonardo that can be used to retrain the model must conform to the following hierarchical structure, that is, under the training, validation and test folders, there are word folders named after the product category, and the ratio of data size is 8:1:1.

Once you have the data for training, the next step is to upload the data to SAP Leonardo's model online storage platform.

In the previous article of Jerry, how to consume applications deployed in SAP Cloud Platform CloudFoundry environment once described how to create a service instance of Leonardo machine learning on SAP cloud platform. The service key of this instance contains an IMAGE_RETRAIN_API_URL, which can be used to obtain the url stored online:

Send a HTTP get request to the url to get the url stored online:

Paste the url into the browser, enter the accessKey and secretKey returned in postman to log in, and you can access the online storage as web:

The next step is to upload the local training files to the online storage deployed on AWS.

First, define a remote site named sapjerrys3 with the command line mc config host, and bind to this site the AWS online storage url,accessKey and secret obtained from postman in the previous step:

Then use the command line to upload the file: mc.exe cp-r C:\ Code\ MachineLearningStudy\ flowersjerry sapjerrys3\ data. After about ten minutes, the file is uploaded:

At this point, you can see that AWS stores the uploaded training files online from the browser.

Now you can submit a background job and let Leonardo process the uploaded files. ABAP consultants can interpret this action as defining a background job in the Netweaver transaction code SM36 and submitting it. To send a HTTP post request, except for the jobName, dataset and modelName in the figure below, all the other fields use the default values defined on the SAP official website.

This request will return a background job ID, copy it down and spell it to the end of url, and then re-send a HTTP get request to query the execution of the job. When Jerry did it, he waited for about five minutes, and the job status changed to SUCCEEDED.

Because the previous exercise and the exercise in this article were done in the CloudFoundry environment of SAP Cloud Platform, we can also use the cf command line to query the execution of these jobs:

Cf sapml retraining jobs-m image

If the job status is FAILED, go to the AWS online storage to check the folder named by the job name, which contains detailed training logs, which can be used for error analysis:

Before the trained model can be officially used, we also need to deploy it, similar to the "activate" action in ABAP Netweaver.

Similar to background jobs that submit training, model deployment is also an asynchronous step. After submitting a deployment request, you get a deployment job ID:ms-26c5a22c-6d07-4164-8222-a4182969162d

You can query the deployment status of the model according to the deployment job ID:

After successful deployment, we can consume the model with Restful API. The format of url is: https://mlfinternalproduction-image-classifier.cfapps.sap.hana.ondemand.com/api/v2/image/classification/models//versions/1.

I randomly found a picture of a sunflower on the Internet.

Send this picture to my retrained and deployed model flowerjerrymodel as a parameter of HTTP POST, and the results show that the retrained model thinks that there is about 87% chance that this picture represents a sunflower.

If I have time, I'm going to collect some alien pictures for training and see if SAP Leonardo can identify the alien pendant hanging on my desk. Thank you for reading.

For more original Jerry articles, please follow the official account "Wang Zixi":

At this point, the study on "how to retrain the machine learning model on SAP Leonardo" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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