Einstein Platform Services

Step 2: Train the Object Detection Dataset

Training the dataset creates the model that delivers the predictions.

  1. Now that the dataset has been created and contains labels and images, it’s time to train the dataset. In this command, replace <TOKEN> with your token and <DATASET_ID> with your dataset ID, and then run it. This command trains the dataset and creates a model with the name specified in the name parameter.
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data"  -F "name=Alpine Boxes on Shelves"  -F "datasetId=1004942" https://api.einstein.ai/v2/vision/train

The response contains information about the training status and looks like the following. Make a note of the modelId because you use this value in the next step.

{
  "datasetId": 1004942,
  "datasetVersionId": 0,
  "name": "Alpine Boxes on Shelves",
  "status": "QUEUED",
  "progress": 0,
  "createdAt": "2017-12-12T18:20:57.000+0000",
  "updatedAt": "2017-12-12T18:20:57.000+0000",
  "learningRate": 0,
  "epochs": 0,
  "queuePosition": 1,
  "modelType": "image-detection",
  "algorithm": "object-detection",
  "language": "N/A",
  "object": "training",
  "modelId": "BN2PTZQ6U2F7ORW57ZIZWZWRDQ",
  "trainParams": null,
  "trainStats": null
}
  1. Training a dataset can take a while depending on how many images the dataset contains. To get the training status, in this command, replace <TOKEN> with your token and <YOUR_MODEL_ID> with the model ID, and then run the command.
curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/vision/train/<YOUR_MODEL_ID>

The response returns the status of the training process. If it’s in progress, you see a status of RUNNING. When the training is complete, it returns a status of SUCCEEDED and a progress value of 1.

{
  "datasetId": 1004942,
  "datasetVersionId": 4090,
  "name": "Alpine Boxes on Shelves",
  "status": "SUCCEEDED",
  "progress": 1,
  "createdAt": "2017-12-12T18:20:57.000+0000",
  "updatedAt": "2017-12-12T18:41:29.000+0000",
  "learningRate": 0.001,
  "epochs": 20,
  "modelType": "image-detection",
  "algorithm": "object-detection",
  "language": "N/A",
  "object": "training",
  "modelId": "BN2PTZQ6U2F7ORW57ZIZWZWRDQ",
  "trainParams": null,
  "trainStats": {
    "labels": 3,
    "examples": 33,
    "averageF1": "NaN",
    "totalTime": "00:20:31:335",
    "transforms": null,
    "trainingTime": "00:19:23:225",
    "earlyStopping": false,
    "lastEpochDone": 20,
    "modelSaveTime": "00:00:25:573",
    "testSplitSize": 2,
    "trainSplitSize": 31,
    "datasetLoadTime": "00:00:01:401",
    "preProcessStats": null,
    "postProcessStats": null
  } 
}

Tell Me More

After you create a model, you can retrieve metrics for each label, such as f1 score, precision, and recall. You can use these values to tune and tweak your model. Use this call to get the model metrics.

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

The command returns a response similar to this one.

{
  "id": "BN2PTZQ6U2F7ORW57ZIZWZWRDQ",
  "metricsData": {
    "labelMetrics": [
      {
        "f1": 1,
        "label": "Alpine - Corn Flakes",
        "recall": [
          0.5,
          1
        ],
        "precision": [
          1,
          1
        ],
        "averagePrecision": 1
      },
      {
        "f1": 0,
        "label": "Alpine - Oat Cereal",
        "recall": null,
        "precision": null,
        "averagePrecision": null
      },
      {
        "f1": 1,
        "label": "Alpine - Bran Cereal",
        "recall": [
          0.5,
          1
        ],
        "precision": [
          1,
          1
        ],
        "averagePrecision": 1
      }
    ],
    "modelMetrics": {
      "trainingLoss": 18.272620260715485,
      "meanAveragePrecision": 1
    }
  },
  "createdAt": "2017-12-12T18:41:29.000+0000",
  "language": "N/A",
  "algorithm": "object-detection",
  "object": "metrics"
}

Updated 3 months ago

Step 2: Train the Object Detection Dataset


Training the dataset creates the model that delivers the predictions.

Suggested Edits are limited on API Reference Pages

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