Einstein Platform Services

Step 1: Create the Dataset

The first step is to create the dataset that contains the beach and mountain images. You use this dataset to create the model.

In the following command, replace <TOKEN> with your JWT token and run the command. This command:

  • Creates a dataset called beachvsmountains from the specified .zip file
  • Creates two labels from the .zip file directories: a Beaches label and a Mountains label
  • Creates 49 examples named for the images in the Beaches directory and gives them the Beaches label
  • Creates 50 examples named for the images in the Mountains directory and gives them the Mountains label

    If you use the Service, Salesforce may make available certain images to you ("Provided Images"), which are licensed from a third party, as part of the Service. You agree that you will only use the Provided Images in connection with the Service, and you agree that you will not: modify, alter, create derivative works from, sell, sublicense, transfer, assign, or otherwise distribute the Provided Images to any third party.

curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "type=image" -F "path=https://einstein.ai/images/mountainvsbeach.zip" https://api.einstein.ai/v2/vision/datasets/upload/sync

This call is synchronous, so you'll see a response after all the images have finished uploading. The response contains the dataset ID and name as well as information about the labels and examples.

{
  "id": 1000044,
  "name": "dataset",
  "createdAt": "2019-02-21T21:59:29.000+0000",
  "updatedAt": "2019-02-21T21:59:29.000+0000",
  "labelSummary": {
    "labels": [
      {
        "id": 1865,
        "datasetId": 1000044,
        "name": "Mountains",
        "numExamples": 50
      },
      {
        "id": 1866,
        "datasetId": 1000044,
        "name": "Beaches",
        "numExamples": 49
      }
    ]
  },
  "totalExamples": 99,
  "totalLabels": 2,
  "available": true,
  "statusMsg": "SUCCEEDED",
  "type": "image",
  "language": "N/A",
  "numOfDuplicates":0,
  "object": "dataset"
}

In this scenario, the API call to create the dataset and upload the image data is synchronous. You can also make an asynchronous call to create a dataset. See Ways to Create a Dataset for more information about when to use the various APIs.

Tell Me More

There are other ways to work with datasets using the API. For example, use this command to return a list of all your datasets.

curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/vision/datasets

The results look something like this.

{
  "object": "list",
  "data": [
    {
      "id": 1000044,
      "name": "mountainvsbeach",
      "createdAt": "2019-02-21T21:59:29.000+0000",
      "updatedAt": "2019-02-21T21:59:29.000+0000",
      "labelSummary": {
      "labels": [
        {
          "id": 1865,
          "datasetId": 1000044,
          "name": "Mountains",
          "numExamples": 50
        },
        {
          "id": 1866,
          "datasetId": 1000044,
          "name": "Beaches",
          "numExamples": 49
        }
      ]
    },
    "totalExamples": 99,
    "totalLabels": 2,
    "available": true,
    "statusMsg": "SUCCEEDED",
    "type": "image",
    "language": "N/A",
    "numOfDuplicates":0,
    "object": "dataset"
   },
   {
      "id": 1000045,
      "name": "Brain Scans",
      "createdAt": "2017-02-21T22:04:06.000+0000",
      "updatedAt": "2017-02-21T22:04:06.000+0000",
      "labelSummary": {
        "labels": []
      },
      "totalExamples": 0,
      "totalLabels": 0,
      "available": true,
      "statusMsg": "SUCCEEDED",
      "type": "image",
      "language": "N/A",
      "numOfDuplicates":0,
      "object": "dataset"
    }
  ]
}

To delete a dataset, use the DELETE verb and pass in the dataset ID.

curl -X DELETE -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/vision/datasets/<DATASET_ID>

The results look something like this.

{
    "id": "BAX46MYCKISDDHM5ZTV7YVZNGE",
    "organizationId": "432215",
    "type": "DATASET",
    "status": "QUEUED",
    "progress": 0,
    "message": null,
    "object": "deletion",
    "deletedObjectId": "1001008"
}

After you delete a dataset, use the id to get the status of the deletion. See Get Deletion Status.

Updated 3 months ago

Step 1: Create the Dataset


The first step is to create the dataset that contains the beach and mountain images. You use this dataset to create the model.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.