Build Custom Models For Image Classification on Einstein Platform
Prerequisites
Set up your Account-- Navigate to Einstein Platform Service Account .
Find your key file-- If you have already created an account, locate the einstein_platform.pem
Find your key file-- If you have already created an account, locate the einstein_platform.pem
file that you have downloaded.
Inastall Curl-- Download it from https://curl.haxx.se/download.htm
-->The Einstein Platform Service APIs use OAuth 2.0 JWT bearer token flow for authorization. Use the Token Page to upload your key file and generate a JWT token.
Step 1: Create Data SetInastall Curl-- Download it from https://curl.haxx.se/download.htm
-->The Einstein Platform Service APIs use OAuth 2.0 JWT bearer token flow for authorization. Use the Token Page to upload your key file and generate a JWT token.
Use the following command
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "type=image" -F "path=http://metamind.io/images/mountainvsbeach.zip" https://api.einstein.ai/v2/vision/datasets/upload/sync
-->Replace <TOKEN> with the token which you got.
Then you will get Json code like this
{
"id":1009061,
"name":"mountainvsbeach",
"createdAt":"2017-08-10T13:49:26.000+0000",
"updatedAt":"2017-08-10T13:49:26.000+0000",
"labelSummary":{
"labels":[
{
"id":90572,
"datasetId":1009061,
"name":"Mountains",
"numExamples":50
},
{
"id":90573,
"datasetId":1009061,
"name":"Beaches",
"numExamples":49
}
]
},
"totalExamples":99,
"totalLabels":2,
"available":true,
"statusMsg":"SUCCEEDED",
"type":"image",
"object":"dataset"
Step 2:Train The DataSet
Use the following command
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "name=Beach and Mountain Model" -F "datasetId=<DATASET_ID>" https://api.einstein.ai/v2/vision/train
-->Replace <Token> and <Data Set Id>
Then you will get Json code like this
{
"datasetId":1009061,
"datasetVersionId":0,
"name":"Beach and Mountain Model",
"status":"QUEUED",
"progress":0,
"createdAt":"2017-08-10T13:52:32.000+0000",
"updatedAt":"2017-08-10T13:52:32.000+0000",
"learningRate":0.0,
"epochs":0,
"queuePosition":3,
"object":"training",
"modelId":"XLCYWVMAW4H25DOXA5E7R65E6I",
"trainParams":null,
"trainStats":null,
"modelType":"image"
Step 3:Classify an Image
For this example, i have referenced this picture by the file Url
Use the following command
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "sampleLocation=http://einstein.ai/images/546212389.jpg" -F "modelId=<YOUR_MODEL_ID>" https://api.einstein.ai/v2/vision/predict
-->Replace <Token> and <Model Id>
Json Code:
{
"probabilities":[
{
"label":"Mountains",
"probability":0.99539346
},
{
"label":"Beaches",
"probability":0.0046065715
}
],
"object":"predictresponse"
}
GREAT JOB
ReplyDelete