You are on page 1of 107

Week 2: Enterprise AI in Action – Defect Detection

Unit 1: SAP AI Overview and Introduction


to SAP AI Core
SAP AI overview and introduction to SAP AI Core
Agenda

SAP AI Strategy and Overview


▪ Introduction to AI
▪ Market overview
▪ AI at SAP
– SAP AI Core and SAP AI Launchpad
– SAP AI Business Services
– SAP Conversational AI
– SAP HANA ML
– SAP Data Intelligence

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SAP AI overview and introduction to SAP AI Core
What is artificial intelligence (AI)?

Advanced analysis
Support decision making
Any means to make machines solve
Artificial Intelligence tasks like humans do Take action

Many applications
Learn through training
Machine Learning Computers can learn from examples
to solve tasks without being explicitly Statistical model
programmed to do so
Manual feature extraction
Artificial Neural Brain-inspired machine learning algorithms
Networks
Multiple layers
Handle complex data
Deep Subset of ML that uses deep artificial
neural networks Enable large datasets
Learning
Advanced applications

https://www.gartner.com/en/topics/artificial-intelligence
https://www.britannica.com/technology/artificial-intelligence
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3
SAP AI overview and introduction to SAP AI Core
Market overview: enterprise applications with embedded AI

The addressable market of enterprise applications with 60%


embedded AI is projected to increase to $136B (2024). of all apps
16% (227B)
CAGR
36%
of all apps
(98B)

197 +15.7%
AI Non-Centric 169
95 106 121 143
AI
Apps
AI Centric 12
14 17 20 25 30 +19.4%

Other Apps 191 178 168 162 157 153 CAGR


(No AI)

$Billion USD 2019 2020 2021 2022 2023 2024

Source: IDC Worldwide Semiannual Artificial Intelligence Tracker, 2H19 – Draft


*Gartner MQ for Data Management for Analytics Jan 2019
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4
SAP AI overview and introduction to SAP AI Core
Artificial intelligence at SAP

SAP is committed to building intelligent and sustainable enterprises


by infusing AI technologies into applications and business scenarios
▪ Embedding AI natively into SAP applications
▪ Exposing AI via SAP Business Technology Platform
▪ Providing AI services to extend SAP systems

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP AI Core Available since
October 12th, 2021

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training
training&&serving
servingAI scenarios©
AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP AI Launchpad Available since
October 12th, 2021

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP AI Business Services

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC


https://api.sap.com/package/SAPLeonardoMLBusinessServices/overview
9
SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP Conversational AI

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC


https://api.sap.com/package/SAPConversationalAI/overview
10
SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP HANA ML

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


SAP AI overview and introduction to SAP AI Core
SAP AI solution portfolio: SAP Data Intelligence

AI embedded Custom Applications AI embedded SAP Applications

manage & operate AI content centrally


AI API standardized integration of AI

SAP AI Launchpad & tooling


SAP AI Business Services
SAP
Conversational
Partner SAP Data SAP HANA Document Business Service Data Attribute …
AI Information Entity Ticket Recommen-
Offerings* Intelligence* (APL, PAL)* Extraction Recognition Intelligence dation

SAP AI Core
Complementary AI runtimes training & serving AI scenarios

SAP Business Technology Platform

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 2: SAP AI Core Deep-Dive Part 1:
Onboarding, Terminology, AI API
SAP AI Core deep-dive part 1: onboarding, terminology, AI API
Agenda

▪ SAP AI Core key components


▪ Terminology
▪ SAP AI Core and AI Launchpad onboarding
– Demo 1:
▫ How to connect AI Core to AI Launchpad
▪ The standard AI API
– The standard AI API and his clients
– The standard AI API specification

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
SAP AI Core key components and architecture

▪ SAP AI Core provides an engine for running any


AI workflows and model serving workloads.
▪ AI API provides a standard way of managing the
AI scenario lifecycle on different runtimes.
▪ SAP AI Launchpad manages the SAP AI Core
runtime by means of the standardized AI API.
▪ SAP AI Core is integrated with third party
tools, widely used for developing cloud-native
applications and AI solutions.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
SAP AI Core onboarding: service instance

▪ SAP AI Core is provided as a reuse service in


SAP BTP Marketplace
▪ Service instance of AI Core = AI Core main
tenant + default resource group
▪ One AI Core main tenant per BTP subaccount
– Multiple AI Core instances from the same
subaccount will point to the same AI Core
main tenant

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
SAP AI Core onboarding: service key

▪ After configuring the AI Core service, we get the


service key needed for authentication purposes
and therefore for managing AI Core through the
AI API.
▪ Keep the service key private. Anyone with these
credentials can access all your assets in AI Core.
▪ Instructions for SAP AI Core provisioning
▪ Instructions for SAP AI Launchpad provisioning

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
SAP AI Launchpad onboarding: service subscription

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
Demo 1: How to connect SAP AI Core to SAP AI Launchpad

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
Terminology

Templates
▪ Templates are used to define the training pipelines and
how a model has to be deployed and served at the level
of the main tenant

Executable
▪ An executable is a template that is instantiated for a
purpose, such as training a model or creating a
deployment

Scenario
▪ A scenario is a group of related executables for a use
case within the user’s tenant

Full AI Core glossary


© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8
SAP AI Core deep-dive part 1: onboarding, terminology, AI API
Terminology

Execution
▪ The operation of executing an executable with a given
configuration

Artifact
▪ A reference to data or a file that is produced or
consumed by an execution or deployment which
typically resides on an object store

Configuration
▪ A collection of parameters, artifact references, and
executables that is used to run an execution or a
deployment

Full AI Core glossary


© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9
SAP AI Core deep-dive part 1: onboarding, terminology, AI API
AI operations

AI API
▪ AI API provides a standard way of managing your artifacts and workflows (such as training scripts, data, models, and model servers).
▪ Open API format, HTTP-based RESTful API definition.

Clients

SDK AI Launchpad operations manager Other clients


▪ SAP AI Core SDK provides a ▪ A multitenant software as a service (SaaS) application on ▪ cURL
programmatic interface to SAP Business Technology Platform to manage AI use cases
across multiple instances of AI runtimes (such as SAP AI ▪ Postman
communicate with SAP AI Core.
Core).

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
AI API specification for ML lifecycle management

▪ Accessing metadata about scenarios and


executables
▪ Starting/updating/stopping executions (training
pipelines) and deployments (model servers)
▪ Managing artifacts (datasets, models)
▪ Getting metrics (by products of executions/models)
▪ AI API Specification

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


SAP AI Core deep-dive part 1: onboarding, terminology, AI API
Lessons learned

▪ SAP AI Core integrates with all the most popular


tools for developing cloud-native AI solutions.
▪ SAP AI Core and SAP AI Launchpad can be
provisioned very easily in SAP BTP.
▪ A service key is fundamental to manage AI Core, for
example through the AI Launchpad interface.
▪ A proper terminology is used to name entities in AI
Core.
▪ The standard AI API allows to manage every aspect
of the AI scenario lifecycle.
▪ Several clients for the AI API are available to manage
AI Core.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 3: SAP AI Core Deep-Dive Part 2: MLOps
SAP AI Core deep-dive part 2: MLOps
Agenda

▪ Code development, containerization and execution in SAP AI Core


▪ Templates and CI/CD in SAP AI Core
– Demo 1:
▫ How to create AI API client in Python
▫ How to connect a GitHub repository to SAP AI Core
▫ How to connect a Docker repository to SAP AI Core
▪ The concept of “application” in SAP AI Core
– Demo 2:
▫ How to create an “application”

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SAP AI Core deep-dive part 2: MLOps
Machine learning workflow and code development

Identify the business challenge


Automatize the inspection of final products

Identify the most suitable AI approach


Defect detection with deep learning-enabled computer vision

Identify the phases of your ML workflow


Collect the data, train the DL model, and make it available online through an endpoint

Training part

Investigate the model architecture and design the training Serving part
pipeline

Design the web application that will use the trained model and
Write the code that executes all the needed steps that will serve the inference requests

Write the code for the web-serving application

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SAP AI Core deep-dive part 2: MLOps
Code containerization and execution

▪ A Docker repository needs to be ▪ SAP AI Core is an abstraction for the

Kubernetes
Docker

connected to SAP AI Core for developing, Kubernetes layer that is used to


shipping, and running applications in orchestrate the Docker container platform.
containers. ▪ Kubernetes assures scalability,
▪ Docker registry secret authorizes SAP AI monitoring, and cross-platform
Core to pull your Docker images from your deployments.
Docker repository.

Container Lifecycle

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SAP AI Core deep-dive part 2: MLOps
Code containerization and execution

Training and serving


codes converted into
Docker images
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5
SAP AI Core deep-dive part 2: MLOps
Templates

Templates are used to define the training pipelines and how a model has to be deployed and served

▪ Workflow templates are used to: ▪ Serving templates are used to deploy one or
– train models more trained models on a model server and rely
– ingest data, pre-process and post-process on KServe
data ▪ KServe provides a standard model inference
– execute batch inference pipelines platform on Kubernetes, regardless of the
framework used to develop the model
▪ Workflow templates are based on the Argo
Workflows workflow engine ▪ KServe supports modern serverless inference
workload with autoscaling including Scale to
▪ Workflow templates instruct AI Core about how
Zero on GPU
to execute the Docker images, what inputs to
provide, what outputs to generate, etc. ▪ Serving templates instruct AI Core about the
container to execute, the model to use, etc.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SAP AI Core deep-dive part 2: MLOps
Example of workflow template

Name of the scenario

Name of the training executable

Docker secret

Resource plan

Input artifact: dataset name and location

Output artifact: model name and location

Container name and location

Execution command of the code within the


Docker image
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7
SAP AI Core deep-dive part 2: MLOps
Example of serving template

Name of the scenario

Name of the serving executable

Name of the input artifact


(i.e. the model produced by the training)

Resource plan

Docker secret and replicas

Container name and location

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SAP AI Core deep-dive part 2: MLOps
GitHub and templates

Workflow and
serving templates

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


SAP AI Core deep-dive part 2: MLOps
CI/CD in SAP AI Core

▪ A GitHub repository contains the declarative descriptions (templates) of the K8s infrastructure currently
desired in SAP AI Core.
▪ An automated process, ArgoCD, makes the underlying K8s infrastructure match the described state in the
repository.
▪ To create a new scenario/executable or update the existing ones, you only need to update the files in the
repository, then ArgoCD handles everything else.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


SAP AI Core deep-dive part 2: MLOps
Demo 1

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


SAP AI Core deep-dive part 2: MLOps
More about Continuous Delivery in SAP AI Core

Git repository SAP AI Core Tenant

Defect
Detection defect-det-app
Training template
Serving template
defect-det-scenario Training executable Serving executable

Docker Registry Data Storage

Defect Detection
Image Dataset
Docker image

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


SAP AI Core deep-dive part 2: MLOps
Demo 2

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13


SAP AI Core deep-dive part 2: MLOps
Lessons learned

▪ In SAP AI Core, workloads and services are


executed in the form of Docker containers thanks to
the underlying Kubernetes infrastructure.
▪ Access to a Docker registry has to be provided to
SAP AI Core.
▪ Declarative configuration files (templates) are used
to instruct AI SAP Core about how to execute the
Docker images, what inputs to provide, what outputs
to generate, etc.
▪ A GitHub repository is needed to host the
configuration files and access has to be granted.
▪ ArgoCD makes the Kubernetes environment match
the described state in the GitHub repository.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 14


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 4: SAP AI Core Deep-Dive Part 3:
Storage Access and Resource Groups
SAP AI Core deep-dive part 3: storage access and resource groups
Agenda

▪ Storage options in SAP AI Core


▪ Resource groups and multitenancy
– Demo:
▫ How to create a resource group
▫ How to connect an AWS S3 bucket
▫ Check all the configurations in SAP AI Launchpad
▪ End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SAP AI Core deep-dive part 3: storage access and resource groups
SAP AI Core key components and architecture

▪ SAP AI Core provides an engine for running


any AI workflows and model serving
workloads.
▪ AI API provides a standard way of managing
the AI scenario lifecycle on different runtimes.
▪ SAP AI Launchpad manages the SAP AI
Core runtime by means of the standardized AI
API.
▪ SAP AI Core is integrated with third party Trained model

tools, widely used for developing cloud-native


applications and AI solutions.

Datasets

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SAP AI Core deep-dive part 3: storage access and resource groups
Storage options in SAP AI Core

The main storage option is a Hyperscaler object store


to connect to SAP AI Core.

Purpose
▪ Hyperscale storage is a storage mechanism with the ability
to massively expand under a controlled and efficient
managed, software-defined framework.

PROs
▪ Cost-effective, robust, and durable, rich tooling.
▪ Data access is handled via the Argo artifacts feature which
copies data in/out of pipeline containers.

Current status
▪ AWS S3 and Azure Blob storage.
▪ Support for SAP HANA Cloud data lake files.

Future roadmap
▪ Adding other hyperscalers (like GCP).
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4
SAP AI Core deep-dive part 3: storage access and resource groups ups
Resource groups and multitenancy

▪ A resource group represents a virtual collection of related resources within the scope of one SAP AI
Core tenant.
▪ SAP AI Core tenants use resource groups to isolate related ML resources and workloads.
▪ Scenarios, executables, and Docker registry secrets are shared across all resource groups.
▪ Runtime entities such as executions, deployments, configurations, and artifacts belong to specific resource
groups and cannot be shared across resource groups.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SAP AI Core deep-dive part 3: storage access and resource groups
Examples of resource group mapping

Service Provider Tenant

Service Service Service


Default
consumer 1 consumer 2 consumer 3

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SAP AI Core deep-dive part 3: storage access and resource groups
Examples of resource group mapping

Service Provider Tenant

Default Dev Test Prod

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SAP AI Core deep-dive part 3: storage access and resource groups
Examples of resource group mapping

Service Provider Tenant

Default Team 1 Team 2 Team 3

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SAP AI Core deep-dive part 3: storage access and resource groups
Examples of resource group mapping

Service Provider Tenant

Business Business Business


Default
service 1 service 2 service 3

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


SAP AI Core deep-dive part 3: storage access and resource groups
Demo

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


SAP AI Core
end-to-end ML workflow

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


SAP AI Core deep-dive part 3: storage access and resource groups
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the
AI Core and Use
Data in S3 Get the Get
AI Submit for Submit for deployment
and create a trained deployment
Launchpad training deployment URL for
resource model URL
onboarding inferencing
group

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


SAP AI Core deep-dive part 3: storage access and resource groups
Lessons learned

▪ In SAP AI Core artifacts (datasets, models) are


stored in hyperscaler object stores.
▪ A hyperscaler object store has to be registered in
SAP AI Core.
▪ Recently also the use of SAP HANA Cloud Data
Lake Files has become possible.
▪ Resource groups allow to segregate AI assets within
the scope of an SAP AI Core tenant.
▪ The main steps of a typical end-to-end ML workflow
in SAP AI Core.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 5: Computer Vision and Defect Detection in
TensorFlow
Computer vision and defect detection in TensorFlow
Agenda

▪ Business challenge: LGP automated defect detection


▪ Computer vision and image segmentation
▪ BYOM: image semantic segmentation model for LGP
automated defect detection
– Introduction to convolutional neural networks
– The U-Net architecture
– Designing the training pipeline
– Monitor your model quality and accuracy
– Coding your training pipeline for SAP AI Core
▪ The computer vision package

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Computer vision and defect detection in TensorFlow
Business challenge: automated defect detection​

Light Guide Plate (LGP)


▪ Optical product which can
transform a linear light source
into a surface light source.
▪ High luminous efficiency, luminance
Sustainability
Goals & Challenges Solution uniformity, long service life, energy
benefits conservation.
▪ Applied in liquid crystal display
screens such as computer monitors,
car navigations, and PADs.
▪ The LGP production lines Deep learning ▪ Reduced waste
must improve quality and techniques have found
▪ Reduced price of end
speed wide application in
product surface defect product
▪ The distribution of the detection and are ▪ Safer work place
LGP points is uneven, suitable for the
and the size, shape, and detection of complex
brightness of the same defects of the LGP
kind of defects are also
different

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Trained AI Models Sales Records Maintenance Orders etc.
▪ Defect Detection Model
Procurement Equipment Inventory
▪ Sound-Based Predictive SAP S4/HANA Cloud
Maintenance Model
Monitoring day-to-day ops
Data
Recording energy
▪ Annotated Defect AI Model Serving APIs consumption Maintenance cost
Images AI models scoring on live planning
▪ Annotated Sound sensors data
Anomalies ▪ Defect detection Production and
AI Model Training
▪ Sound-based predictive Sustainability and
Cloud Storage maintenance KPIs monitoring
Placing proactive
SAP AI Core maintenance orders in S/4
& SAP AI Launchpad Smart Factory App SAP Analytics Cloud

SAP Business Technology Platform


Microphones Data Batches
Camera Data Batches

IoT Gateway

x6

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Computer vision and defect detection in TensorFlow
Computer vision: purpose and tasks

Computer vision

Computer vision is an interdisciplinary scientific field that deals with how computers can gain high-level
understanding from digital images or videos.

Classification Object Detection Segmentation Generation Restoration

Single object Multiple object


https://www.v7labs.com/blog/what-is-computer-vision
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5
Computer vision and defect detection in TensorFlow
Image segmentation and some of its applications

Industrial inspection
Image segmentation

Self-driving cars

Medical scans

Satellite imagery

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Computer vision and defect detection in TensorFlow
What is a CNN?

▪ A convolutional neural network (CNN) is a deep learning algorithm which can take in an input image,
assign importance to various aspects/objects in the image and be able to differentiate one from the other.
▪ The architecture of a CNN is analogous to that of the connectivity pattern of neurons in the human brain and
was inspired by the organization of the visual cortex.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Computer vision and defect detection in TensorFlow
A model architecture for image segmentation: U-Net

▪ U-Net is an image segmentation model Contracting path Expanding path


architecture that has become very
popular (Ronneberger et al. 2015).
▪ The basic idea of the U-Net is to:
– first obtain a lower-dimensional
representation of the image through a
traditional convolutional neural network;
– then upsample that low-dimensional
representation to produce the final
output segmentation map: a binary
mask of 1s and 0s for each pixel, where
1 indicates a defect and 0 indicates
background.

MobileNetV2 pix2pix

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Computer vision and defect detection in TensorFlow
Designing the training pipeline

Load surface images (OpenCV) Pre-processing (OpenCV) Build U-Net (TensorFlow) Train the model

Modified U-Net
Normal surface

MobileNet
V2

Defected surface

pix2pix
upsample
block
Mask/ground truth

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Computer vision and defect detection in TensorFlow
Focus on the loss function and metrics

▪ The Intersection-Over-Union (IoU) is one of the most ▪ Overlap = number of pixels


commonly used metrics in semantic segmentation. belonging to the defect class shared
▪ This metric ranges from 0 to 1 with 0 signifying no overlap among prediction and ground truth
and 1 signifying perfectly overlapping segmentation. ▪ Union = sum of the number of
▪ We defined a specific and more suitable loss function for pixels belonging to the defect class
our use case: 1- IoU. in the prediction and ground truth
minus the overlap

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


Computer vision and defect detection in TensorFlow
Prepare the code to run in SAP AI Core

The key point is to prepare some structured code


(a Python class, for example) which implements all
the required steps in the pipeline:
▪ read_dataset: load the images and apply some
pre-processing;
▪ split_dataset: split the dataset;
▪ build_model: build the chosen model;
▪ init_model: initialize and compile the model;
▪ train_model: configure the training and execute it;
▪ save_model: save the model;
▪ get_model: load the model;
▪ model_metrics: define and register the desired
metrics in SAP AI Core.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


Computer vision and defect detection in TensorFlow
The computer vision package

▪ The computer vision package helps with the implementation


of computer vision use-cases on top of SAP AI Core.
▪ It extends detectron2, a state-of-the-art library for object
detection and image segmentation.
▪ Our package adds image classification and feature
extraction capabilities.
▪ The package offers training and evaluation methods and
other helpful components, such as a large set of
augmentation functions.
▪ The package can also be used standalone without AI Core,
and AI Core integration can be added to the project later.
– https://pypi.org/project/sap-computer-vision-package/
– https://developers.sap.com/tutorials/cv-package-aicore-train-
object-detection.html

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


Computer vision and defect detection in TensorFlow
Lessons learned

▪ Advanced computer vision is the best approach to


automate the product inspection in Bagnoli & CO.
▪ CNN is the most popular and effective choice for
implementing an accurate visual automatic
inspection.
▪ SAP AI Core allows to train and exploit any custom
model built by profiting from the tools and knowledge
available in the Open Source community.
▪ Designing the training pipeline and translating it into
code is fundamental to run it in AI Core.
▪ In SAP AI Core it is possible to easily monitor the
performance of your model.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 6: Defect Detection Training with
SAP AI Core SDK
Defect detection training with SAP AI Core SDK
Agenda

▪ Model training in SAP AI Core


▪ Demos:
– How to convert a training Python code to a Docker image
– How to create a training configuration
– How to run and check the training
– How to retrieve the metrics from SAP AI Core

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Defect detection training with SAP AI Core SDK
Machine learning workflow and code development

Identify the business challenge


Automatize the inspection of final products

Identify the most suitable AI approach


Defect detection with deep learning-enabled computer vision

Identify the phases of your ML workflow


Collect the data, train the DL model, and make it available online through an endpoint

Training part

Investigate the model architecture and design the training Serving part
pipeline

Design the web application that will use the trained model and
Write the code that executes all the needed steps that will serve the inference requests

Write the code for the web serving application

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Defect detection training with SAP AI Core SDK
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the Submit for Get the trained
Use
AI Core and data in S3 training (using model Get
Submit for deployment
AI Launchpad and create a customer’s (registered as deployment
deployment URL for
onboarding resource training artifact URL
inferencing
group scripts) automatically)

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Defect detection training with SAP AI Core SDK
Convert the training Python code to a Docker image

docker login docker.io -u YOUR_DOCKER_REPO

docker push docker.io/YOUR_DOCKER_REPO/image-seg-train:0.0.1

docker buildx build -o type=docker --platform=linux/amd64 -t YOUR_DOCKER_REPO/image-seg-train:0.0.1 .

Training Dockerfile requirements.txt train.py

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Defect detection training with SAP AI Core SDK
Focus on the training Dockerfile

Load an official Docker image with


Python and all the TensorFlow
dependencies for GPUs

Add path pointing to the NVIDIA libraries


for using GPUs

Install all the packages specified in the


requirements.txt file

For retrieving the pix2pix upsample block

Create all the directories needed to host:


the code to run, the output model, the
dataset copied from the AWS S3 bucket

It copies the train.py from the local folder


to the previously created path

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Defect detection training with SAP AI Core SDK
Demo: How to convert a training Python code to a Docker image

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Defect detection training with SAP AI Core SDK
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the Submit for Get the trained
Use
AI Core and data in S3 training (using model Get
Submit for deployment
AI Launchpad and create a customer’s (registered as deployment
deployment URL for
onboarding resource training artifact URL
inferencing
group scripts) automatically)

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Defect detection training with SAP AI Core SDK
Demo: How to create a training configuration and how to run and check the training

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Defect detection training with SAP AI Core SDK
Focus on the loss function and metrics

▪ The Intersection-Over-Union (IoU) is one of the most ▪ Overlap = number of pixel


commonly used metric in semantic segmentation. belonging to the defect class shared
▪ This metric ranges from 0 to 1 with 0 signifying no overlap among prediction and ground truth
and 1 signifying perfectly overlapping segmentation. ▪ Union = sum of the number of pixel
▪ We defined a specific and more suitable loss function for belonging to the defect class in the
our use case: 1- IoU. prediction and ground truth minus
the overlap

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


Defect detection training with SAP AI Core SDK
Demo: How to retrieve the metrics from AI Core

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


Defect detection training with SAP AI Core SDK
Lessons learned

▪ The code prepared for implementing the training pipeline has to be


converted into one or more Docker images that are then uploaded
to the remote Docker registry.
▪ A workflow template has to be prepared and uploaded to the GitHub
repository.
▪ The workflow template is written by following the Argo Workflow
engine specifications and reflects the pipeline structure.
– Metaflow plugin for generating multi-step Argo templates:
▫ Metaflow library for SAP AI Core
▫ Train your model in SAP AI Core using the Metaflow-Argo plugin
▪ The training pipeline can be easily run and monitored by means of
the available endpoints.
▪ The model accuracy and quality can be monitored by defining/
retrieving the metrics in/from AI Core by means of specific
endpoints.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: Enterprise AI in Action – Defect Detection
Unit 7: Defect Detection Serving with
SAP AI Core SDK
Defect detection serving with SAP AI Core SDK
Agenda

▪ Model deploying in SAP AI Core


▪ Demos:
– How to convert a serving Python code to a Docker image
– How to create a serving configuration
– How to deploy a model in SAP AI Core
– How to make an inference with the deployed model

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Defect detection serving with SAP AI Core SDK
Machine learning workflow and code development

Identify the business challenge


Automatize the inspection of final products

Identify the most suitable AI approach


Defect detection with deep learning-enabled computer vision

Identify the phases of your ML workflow


Collect the data, train the DL model, and make it available online through an endpoint

Training part

Investigate the model architecture and design the training Serving part
pipeline

Design the web application that will use the trained model and
Write the code that executes all the needed steps that will serve the inference requests

Write the code for the web serving application

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Defect detection serving with SAP AI Core SDK
Serving application workflow

Custom consuming SAP AI Core


service
Serving application

API call Prepare the data Load the DL model


▪ Image is provided in the ▪ Decode binary string ▪ Download the model from the
form of a binary string in ▪ Apply pre-processing, resize object store
the body of the call and normalize the image

Prepare the response Make an inference


▪ Convert with the mask to a ▪ Produce a segmentation map
Response binary string from the prediction
▪ Return the defected area ▪ Calculate the defected area
together with the binary string

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC https://flask.palletsprojects.com/en/2.1.x/ 4
Defect detection serving with SAP AI Core SDK
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the Submit for Get the trained
Use
AI Core and data in S3 training (using model Get
Submit for deployment
AI Launchpad and create a customer’s (registered as deployment
deployment URL for
onboarding resource training artifact URL
inferencing
group scripts) automatically)

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Defect detection serving with SAP AI Core SDK
Convert the serving Python code to a Docker image

docker login docker.io -u YOUR_DOCKER_REPO

docker push docker.io/YOUR_DOCKER_REPO/image-seg-train:0.0.1

docker buildx build -o type=docker --platform=linux/amd64 -t YOUR_DOCKER_REPO/image-seg-train:0.0.1 .

Serving Dockerfile requirements.txt train.py

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Defect detection serving with SAP AI Core SDK
Focus on the serving Dockerfile

Load an official Docker image with


Python and all the TensorFlow
dependencies for GPUs

Add path pointing to the NVIDIA libraries


for using GPUs

Install all the packages specified in the


requirements.txt file

Create the directory needed to host the


code to run

It copies the infer.py from the local folder


to the previously created path

Start the WSGI server to run our Python


web application
https://gunicorn.org/
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7
Defect detection serving with SAP AI Core SDK
Demo: How to convert a serving Python code to a Docker image

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Defect detection serving with SAP AI Core SDK
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the Submit for Get the trained
Use
AI Core and data in S3 training (using model Get
Submit for deployment
AI Launchpad and create a customer’s (registered as deployment
deployment URL for
onboarding resource training artifact URL
inferencing
group scripts) automatically)

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Defect detection serving with SAP AI Core SDK
Demo: How to create a serving configuration and how to deploy a model in AI Core

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


Defect detection serving with SAP AI Core SDK
End-to-end ML workflow in SAP AI Core and SAP AI Launchpad

2.1 Docker: Create own Docker image

0.1 SAP BTP: Create AI Core and AI 2.2 Git: Create a training workflow 4.1 Docker: Create own Docker image
Launchpad instances 2.3 AI Core: Choose the scenario 4.2 Git: Create a serving template
0.2 AI Launchpad: Connect the AI Core 2.4 AI Core: Register input dataset as an 4.3 AI Core: Choose the scenario
runtime to AI Launchpad artifact
0.3 4.4 AI Core: Create a configuration
AI Core: create an AI API client 2.5 AI Core: Create a configuration
4.5 AI Core: Trigger the serving execution
0.4 AI Core: Connect a GitHub repo 2.6 AI Core: Trigger the workflow
execution 4.6 AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment, check the logs
2.7 AI Launchpad: Check the status of
execution, check the logs

0 1 2 3 4 5 6
Upload the Submit for Get the trained
Use
AI Core and data in S3 training (using model Get
Submit for deployment
AI Launchpad and create a customer’s (registered as deployment
deployment URL for
onboarding resource training artifact URL
inferencing
group scripts) automatically)

AI Core one-time initial configuration ML model training ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


Defect detection serving with SAP AI Core SDK
Demo: How to make an inference with the deployed model in Postman

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


Defect detection serving with SAP AI Core SDK
Deployment of pre-trained models
https://developers.sap.com/tutorials/ai-core-tensorflow-byod.html

Docker: Create own Docker image


0.1 SAP BTP: Create AI Core and AI 4.1 Docker: Create own docker Image
Launchpad instances Git: Create a serving template
4.2 Git: Create a Serving template
0.2 AI Launchpad: Connect the AI Core
4.3 AI
AI Core:
Core:Choose
Choosethe scenario
the Scenario
runtime to AI Launchpad
0.3 AI Core: create an AI API client
4.4 AI Core:
AI Core:Create
Createa aconfiguration
Configuration

4.5 AI Core:
AI Core:Trigger
Triggerthe
the Serving
serving Execution
execution
0.4 AI Core: Connect a GitHub repo
4.6 AI Launchpad: Check the status of
AI Launchpad: Check the status of
0.5 AI Core: Connect a Docker repo deployment,check
deployment, checkthe
the logs
logs

0 2 3 4 5 6
Get the pre-
Use
AI Core and Create a trained model Get
Submit for deployment
AI Launchpad resource from open deployment
deployment URL for
onboarding group source URL
inferencing
framework
and register it
as artifact
AI Core one-time initial configuration ML model Inferencing

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13


Defect detection serving with SAP AI Core SDK
Lessons learned

▪ A web application for serving the training model has


to be designed and coded.
▪ The serving application code has to be converted
into a Docker image that is then uploaded to the
remote Docker registry.
▪ A serving template has to be prepared and uploaded
into the GitHub repository in order to instruct AI Core
about the Docker image to execute and the needed
resources.
▪ The web application can be easily started and
managed by means of the available endpoints.
▪ Pre-trained models can be easily registered in AI
Core and made available online by exposing an
endpoint with the very same deployment procedure.

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 14


Defect detection serving with SAP AI Core SDK
Useful links

SAP-specific
▪ AI Core help page
▪ AI Launchpad help page
▪ SAP BTP help page
▪ SAP AI Portfolio blog post

Technical Links
▪ VS code plugin for AI Core
▪ SAP Computer Vision Package
▪ Metaflow library for SAP AI Core

© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 15


Defect detection serving with SAP AI Core SDK
Additional material

Specific to this course


▪ “Building Intelligent Scenarios and Sustainability on SAP BTP” blog
post series
▪ “Building Intelligent Scenarios and Sustainability on SAP BTP”
GitHub repository

Tutorials
▪ SAP HANA Academy video series about the AI Core and AI
Launchpad onboarding
▪ SAP HANA Academy video series about Defect Detection with
TensorFlow in AI Core
▪ Create Your First Machine Learning Project using SAP AI Core
▪ Use Pre-Trained TensorFlow Models with a GPU in SAP AI Core
▪ Create an Object Detection Project using Computer Vision Package
and SAP AI Core
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 16
Defect detection serving with SAP AI Core SDK
Useful links

Data science-specific
▪ https://www.britannica.com/technology/artificial-intelligence
▪ https://ml-ops.org/content/end-to-end-ml-workflow
▪ https://www.v7labs.com/blog/image-segmentation-guide
▪ https://towardsdatascience.com/a-comprehensive-guide-to-
convolutional-neural-networks-the-eli5-way-3bd2b1164a53
▪ https://www.v7labs.com/blog/data-preprocessing-guide
▪ https://resources.github.com/ci-cd/
▪ https://ubuntu.com/blog/kubernetes-versus-docker
▪ https://www.v7labs.com/blog/what-is-computer-vision
▪ https://neptune.ai/blog/performance-metrics-in-machine-learning-
complete-guide
▪ https://www.analyticsvidhya.com/blog/2017/09/common-machine-
learning-algorithms/
© 2022 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 17
Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2022 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.

You might also like