Lars Gregori, SAP CX
27.06.2019
SAP Stammtisch
SAP Leonardo Machine Learning
100% Stammtisch
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "2
►Image Processing
►Text Processing
►Similarity Scoring
►Re-Train and Bring Your Own Model
►Image Processing
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "4
API Business Hub - SAP Leonardo Machine Learning Foundation
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "5
• Inference Service for Customizable Image Classification
• Product Image Classification API
• Inference Service for Face Detection
• Inference Service for Human Detection
• Inference Service for Multi-Instance Image Segmentation
• Inference Service for Scene Text Recognition
• Inference Service for Optical Character Recognition (OCR)
Image Processing
Inference Service for Customizable Image Classification
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "7
Neuronal Net
Hidden-LayerInput-Layer
x×w11
+b11
x×w12
+b12
x×w13
+b13
x×w14
+b14
Output-Layer
Source: http://sappress.de/4795
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "8
CNN - Convolutional Layer
1 2
3 4
7 0
0 -1
3
Input Filter Output
Convolutional Layer Convolutional LayerConvolutional Kernel
Source: http://sappress.de/4795
Demo Image Classification
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "10
SDK and Code Snippet
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "11
https://api.sap.com/api/image_classification_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_01_ImageClassificationService (API)
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_01_ImageClassifierTest (SDK)
DEMO - Inference Service for Customizable Image Classification
Demo Product Image Classification API
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "13
https://api.sap.com/api/product_image_classification_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_01_ImageClassificationService (API)
DEMO - Product Image Classification API
Inference Service for Face Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "15
Modern Face Recognition with Deep Learning
https://medium.com/@ageitgey/machine-learning-is-fun-part-4-modern-face-recognition-with-deep-
learning-c3cffc121d78
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "17
Feature Extraction
Source: http://sappress.de/4795
Demo Face Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "19
https://api.sap.com/api/face_detection_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_03_FaceDetection
DEMO - Inference Service for Face Detection
Demo Inference Service for Human Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "21
https://api.sap.com/api/human_detection_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_04_HumanDetection
DEMO - Inference Service for Human Detection
Inference Service for Multi-Instance Image Segmentation
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "23
Mask RCNN - https://github.com/matterport/Mask_RCNN
Inference Service for Scene Text Recognition
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "25
Inference Service for Scene Text Recognition
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "26
Scene Text Recognition (meter reader)
Demo Scene Text Recognition
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "28
https://api.sap.com/api/scene_text_recognition_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_06_SceneTextRecognition
DEMO - Inference Service for Scene Text Recognition
Inference Service for Optical Character Recognition (OCR)
Demo Optical Character Recognition (OCR)
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "31
https://api.sap.com/api/ocr_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
07_Anwendungen_zur_Bilderkennung/07_07_Ocr
DEMO - Inference Service for Optical Character Recognition (OCR)
►Text Processing
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "33
• Inference Service for Language Detection
• Inference Service for Machine Translation
• Product Text Classification API
• Inference Service for Topic Detection
Text Processing
Inference Service for Language Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "35
LangID
Stand-alone language identification system
https://github.com/saffsd/langid.py
Inference Service for Language Detection
Demo Language Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "37
https://api.sap.com/api/language_detection_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
08_Anwendungen_zur_Texterkennung/08_TextServices
DEMO - Inference Service for Language Detection
Inference Service for Machine Translation
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "39
https://api.sap.com/api/translation_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
08_Anwendungen_zur_Texterkennung/08_TextServices
DEMO - Inference Service for Machine Translation
Product Text Classification API
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "41
https://api.sap.com/api/product_text_classification_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
08_Anwendungen_zur_Texterkennung/08_TextServices
DEMO - Product Text Classification API
Inference Service for Topic Detection
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "43
https://api.sap.com/api/topic_detection_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
08_Anwendungen_zur_Texterkennung/08_PlayList
DEMO - Inference Service for Topic Detection
►Similarity Scoring
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "45
• Inference Service for Similarity Scoring
• Inference Service For Customizable Image Feature Extraction
• Inference Service for Document Feature Extraction
• Inference Service for Face Feature Extraction
Similarity Scoring
Inference Service for Similarity Scoring
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "47
Cosine Similarity
Theta
Demo Similarity Scoring
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "49
https://api.sap.com/api/similarity_scoring_api/resource
DEMO - Inference Service for Similarity Scoring
Inference Service for Document Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "51
Inference Service for Document Feature Extraction
Source: http://sappress.de/4795
Demo Document Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "53
https://api.sap.com/api/document_feature_extraction_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
09_Anwendungen_zur_Aehnlichkeitsbewertung/09_01_DocumentFeatureExtraction
DEMO - Inference Service for Document Feature Extraction
Inference Service for Face Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "55
Modern Face Recognition with Deep Learning
https://medium.com/@ageitgey/machine-learning-is-fun-part-4-modern-face-recognition-with-deep-
learning-c3cffc121d78
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "56
Inference Service for Face Feature Extraction
Source: http://sappress.de/4795
Demo Face Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "58
https://api.sap.com/api/face_feature_extraction_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
09_Anwendungen_zur_Aehnlichkeitsbewertung/09_02_FaceFeatureDetection
DEMO - Inference Service for Face Feature Extraction
Inference Service for Customizable Image Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "60
Feature Extraction
Source: http://sappress.de/4795
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "61
Inference Service for Customizable Image Feature Extraction
Source: http://sappress.de/4795
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "62
Inference Service for Customizable Image Feature Extraction
Source: http://sappress.de/4795
Demo Customizable Image Feature Extraction
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "64
https://api.sap.com/api/img_feature_extraction_api/resource
https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/
09_Anwendungen_zur_Aehnlichkeitsbewertung/09_03_Shoes
DEMO - Inference Service for Customizable Image Feature Extraction
►Re-Train and Bring Your Own Model
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "66
• Activate SAP Leonardo ML on SCP Trial
• Re-Train Images
• Re-Train Text
• Bring Your Own Model (BYOM)
Re-Train and Bring Your Own Model
Activate SAP Leonardo ML on SCP Trial
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "68
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "69
Re-Train Images
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "71
Re-Train Images
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "72
https://blogs.sap.com/2018/11/04/retrain-an-image-classification-model-with-postman-and-sap-
leonardo-machine-learning-foundation-on-sap-cloud-platform-trial/
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "73
Re-Train Text
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "75
https://blogs.sap.com/2018/12/03/retrain-a-text-classification-with-postman-and-sap-leonardo-
machine-learning-foundation-on-sap-cloud-platform-trial-sentiment-analysis/
Bring Your Own Model (BYOM)
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "77
BYOM
http://sappress.de/4795
Deploy BYOM
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "79
BYOM - Deploy Modell
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "80
BYOM - Deploy Modell
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "81
BYOM - Deploy Modell
BYOM Cloud Foundry
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "83
applications:
- name: xor
memory: 1024M
buildpack: python_buildpack
command: python app.py
env:
MODEL_NAME: xor
MODEL_VERSION: 3
DEPLOYMENT_URL: https://mlfproduction-deployment-api.cfapps.eu10.hana.ondemand.com
services:
- ml
BYOM - manifest.yaml (Cloud Foundry)
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "84
grpcio==1.12.1
tensorflow==1.8.0
tensorflow-serving-api==1.8.0
requests
flask
BYOM - requirements.txt
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "85
deployment_url = DEPLOYMENT_URL + "/api/v2/modelServers"
token = globals.request.headers.get("Authorization")
headers = {

'Authorization': token,

'Cache-Control': "no-cache"

}
query = {"modelName": MODEL_NAME, "modelVersion": MODEL_VERSION}
response = requests.request("GET", deployment_url,
headers=headers, params=query)
model_info = json.loads(response.text)
BYOM - app.py
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "86
model_info = model_info["modelServers"][0]
endpoint = model_info["endpoints"][0]
credentials = implementations.ssl_channel_credentials(
root_certificates=str(endpoint["caCrt"]))
channel = implementations.secure_channel(
str(endpoint["host"]),
int(endpoint["port"]),
credentials)
BYOM - app.py
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "87
request = predict_pb2.PredictRequest()
request.model_spec.name = MODEL_NAME
request.model_spec.signature_name = 'serving_default'
tfutil = tf.contrib.util
t_proto = tfutil.make_tensor_proto(data, shape=[1, len(data)],
dtype="float")
request.inputs["dense_1_input:0"].CopyFrom(t_proto)
predict = stub.Predict(request)
res = predict.outputs['dense_2/Sigmoid:0'].float_val[0]
return str(res)
BYOM - app.py
Demo BYOM Application
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "89
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "90
BYOM Anwendung
Fiori App SCP Python App
Modell
Token/
Same-origin policy gRPC

caCrt
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ "91
http://sappress.de/4795
https://github.com/choas/sap-leonardo
Some Links
Contact information:
Lars Gregori
Technology Strategist
SAP Customer Experience Labs
@choas
Thank you.
http://sappress.de/4795

SAP Leonardo Machine Learning

  • 1.
    Lars Gregori, SAPCX 27.06.2019 SAP Stammtisch SAP Leonardo Machine Learning 100% Stammtisch
  • 2.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "2 ►Image Processing ►Text Processing ►Similarity Scoring ►Re-Train and Bring Your Own Model
  • 3.
  • 4.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "4 API Business Hub - SAP Leonardo Machine Learning Foundation
  • 5.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "5 • Inference Service for Customizable Image Classification • Product Image Classification API • Inference Service for Face Detection • Inference Service for Human Detection • Inference Service for Multi-Instance Image Segmentation • Inference Service for Scene Text Recognition • Inference Service for Optical Character Recognition (OCR) Image Processing
  • 6.
    Inference Service forCustomizable Image Classification
  • 7.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "7 Neuronal Net Hidden-LayerInput-Layer x×w11 +b11 x×w12 +b12 x×w13 +b13 x×w14 +b14 Output-Layer Source: http://sappress.de/4795
  • 8.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "8 CNN - Convolutional Layer 1 2 3 4 7 0 0 -1 3 Input Filter Output Convolutional Layer Convolutional LayerConvolutional Kernel Source: http://sappress.de/4795
  • 9.
  • 10.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "10 SDK and Code Snippet
  • 11.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "11 https://api.sap.com/api/image_classification_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_01_ImageClassificationService (API) https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_01_ImageClassifierTest (SDK) DEMO - Inference Service for Customizable Image Classification
  • 12.
    Demo Product ImageClassification API
  • 13.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "13 https://api.sap.com/api/product_image_classification_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_01_ImageClassificationService (API) DEMO - Product Image Classification API
  • 14.
    Inference Service forFace Detection
  • 15.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "15 Modern Face Recognition with Deep Learning https://medium.com/@ageitgey/machine-learning-is-fun-part-4-modern-face-recognition-with-deep- learning-c3cffc121d78
  • 17.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "17 Feature Extraction Source: http://sappress.de/4795
  • 18.
  • 19.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "19 https://api.sap.com/api/face_detection_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_03_FaceDetection DEMO - Inference Service for Face Detection
  • 20.
    Demo Inference Servicefor Human Detection
  • 21.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "21 https://api.sap.com/api/human_detection_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_04_HumanDetection DEMO - Inference Service for Human Detection
  • 22.
    Inference Service forMulti-Instance Image Segmentation
  • 23.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "23 Mask RCNN - https://github.com/matterport/Mask_RCNN
  • 24.
    Inference Service forScene Text Recognition
  • 25.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "25 Inference Service for Scene Text Recognition
  • 26.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "26 Scene Text Recognition (meter reader)
  • 27.
    Demo Scene TextRecognition
  • 28.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "28 https://api.sap.com/api/scene_text_recognition_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_06_SceneTextRecognition DEMO - Inference Service for Scene Text Recognition
  • 29.
    Inference Service forOptical Character Recognition (OCR)
  • 30.
    Demo Optical CharacterRecognition (OCR)
  • 31.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "31 https://api.sap.com/api/ocr_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 07_Anwendungen_zur_Bilderkennung/07_07_Ocr DEMO - Inference Service for Optical Character Recognition (OCR)
  • 32.
  • 33.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "33 • Inference Service for Language Detection • Inference Service for Machine Translation • Product Text Classification API • Inference Service for Topic Detection Text Processing
  • 34.
    Inference Service forLanguage Detection
  • 35.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "35 LangID Stand-alone language identification system https://github.com/saffsd/langid.py Inference Service for Language Detection
  • 36.
  • 37.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "37 https://api.sap.com/api/language_detection_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 08_Anwendungen_zur_Texterkennung/08_TextServices DEMO - Inference Service for Language Detection
  • 38.
    Inference Service forMachine Translation
  • 39.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "39 https://api.sap.com/api/translation_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 08_Anwendungen_zur_Texterkennung/08_TextServices DEMO - Inference Service for Machine Translation
  • 40.
  • 41.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "41 https://api.sap.com/api/product_text_classification_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 08_Anwendungen_zur_Texterkennung/08_TextServices DEMO - Product Text Classification API
  • 42.
    Inference Service forTopic Detection
  • 43.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "43 https://api.sap.com/api/topic_detection_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 08_Anwendungen_zur_Texterkennung/08_PlayList DEMO - Inference Service for Topic Detection
  • 44.
  • 45.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "45 • Inference Service for Similarity Scoring • Inference Service For Customizable Image Feature Extraction • Inference Service for Document Feature Extraction • Inference Service for Face Feature Extraction Similarity Scoring
  • 46.
    Inference Service forSimilarity Scoring
  • 47.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "47 Cosine Similarity Theta
  • 48.
  • 49.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "49 https://api.sap.com/api/similarity_scoring_api/resource DEMO - Inference Service for Similarity Scoring
  • 50.
    Inference Service forDocument Feature Extraction
  • 51.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "51 Inference Service for Document Feature Extraction Source: http://sappress.de/4795
  • 52.
  • 53.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "53 https://api.sap.com/api/document_feature_extraction_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 09_Anwendungen_zur_Aehnlichkeitsbewertung/09_01_DocumentFeatureExtraction DEMO - Inference Service for Document Feature Extraction
  • 54.
    Inference Service forFace Feature Extraction
  • 55.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "55 Modern Face Recognition with Deep Learning https://medium.com/@ageitgey/machine-learning-is-fun-part-4-modern-face-recognition-with-deep- learning-c3cffc121d78
  • 56.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "56 Inference Service for Face Feature Extraction Source: http://sappress.de/4795
  • 57.
  • 58.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "58 https://api.sap.com/api/face_feature_extraction_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 09_Anwendungen_zur_Aehnlichkeitsbewertung/09_02_FaceFeatureDetection DEMO - Inference Service for Face Feature Extraction
  • 59.
    Inference Service forCustomizable Image Feature Extraction
  • 60.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "60 Feature Extraction Source: http://sappress.de/4795
  • 61.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "61 Inference Service for Customizable Image Feature Extraction Source: http://sappress.de/4795
  • 62.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "62 Inference Service for Customizable Image Feature Extraction Source: http://sappress.de/4795
  • 63.
    Demo Customizable ImageFeature Extraction
  • 64.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "64 https://api.sap.com/api/img_feature_extraction_api/resource https://github.com/choas/Machine-Learning-mit-SAP-Leonardo/tree/master/ 09_Anwendungen_zur_Aehnlichkeitsbewertung/09_03_Shoes DEMO - Inference Service for Customizable Image Feature Extraction
  • 65.
    ►Re-Train and BringYour Own Model
  • 66.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "66 • Activate SAP Leonardo ML on SCP Trial • Re-Train Images • Re-Train Text • Bring Your Own Model (BYOM) Re-Train and Bring Your Own Model
  • 67.
    Activate SAP LeonardoML on SCP Trial
  • 68.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "68
  • 69.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "69
  • 70.
  • 71.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "71 Re-Train Images
  • 72.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "72 https://blogs.sap.com/2018/11/04/retrain-an-image-classification-model-with-postman-and-sap- leonardo-machine-learning-foundation-on-sap-cloud-platform-trial/
  • 73.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "73
  • 74.
  • 75.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "75 https://blogs.sap.com/2018/12/03/retrain-a-text-classification-with-postman-and-sap-leonardo- machine-learning-foundation-on-sap-cloud-platform-trial-sentiment-analysis/
  • 76.
    Bring Your OwnModel (BYOM)
  • 77.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "77 BYOM http://sappress.de/4795
  • 78.
  • 79.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "79 BYOM - Deploy Modell
  • 80.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "80 BYOM - Deploy Modell
  • 81.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "81 BYOM - Deploy Modell
  • 82.
  • 83.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "83 applications: - name: xor memory: 1024M buildpack: python_buildpack command: python app.py env: MODEL_NAME: xor MODEL_VERSION: 3 DEPLOYMENT_URL: https://mlfproduction-deployment-api.cfapps.eu10.hana.ondemand.com services: - ml BYOM - manifest.yaml (Cloud Foundry)
  • 84.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "84 grpcio==1.12.1 tensorflow==1.8.0 tensorflow-serving-api==1.8.0 requests flask BYOM - requirements.txt
  • 85.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "85 deployment_url = DEPLOYMENT_URL + "/api/v2/modelServers" token = globals.request.headers.get("Authorization") headers = {
 'Authorization': token,
 'Cache-Control': "no-cache"
 } query = {"modelName": MODEL_NAME, "modelVersion": MODEL_VERSION} response = requests.request("GET", deployment_url, headers=headers, params=query) model_info = json.loads(response.text) BYOM - app.py
  • 86.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "86 model_info = model_info["modelServers"][0] endpoint = model_info["endpoints"][0] credentials = implementations.ssl_channel_credentials( root_certificates=str(endpoint["caCrt"])) channel = implementations.secure_channel( str(endpoint["host"]), int(endpoint["port"]), credentials) BYOM - app.py
  • 87.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "87 request = predict_pb2.PredictRequest() request.model_spec.name = MODEL_NAME request.model_spec.signature_name = 'serving_default' tfutil = tf.contrib.util t_proto = tfutil.make_tensor_proto(data, shape=[1, len(data)], dtype="float") request.inputs["dense_1_input:0"].CopyFrom(t_proto) predict = stub.Predict(request) res = predict.outputs['dense_2/Sigmoid:0'].float_val[0] return str(res) BYOM - app.py
  • 88.
  • 89.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "89
  • 90.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "90 BYOM Anwendung Fiori App SCP Python App Modell Token/ Same-origin policy gRPC
 caCrt
  • 91.
    © 2019 SAPSE or an SAP affiliate company. All rights reserved. ǀ "91 http://sappress.de/4795 https://github.com/choas/sap-leonardo Some Links
  • 92.
    Contact information: Lars Gregori TechnologyStrategist SAP Customer Experience Labs @choas Thank you. http://sappress.de/4795