

# Labeling images


A label identifies an object, scene, concept, or bounding box around an object in an image. For example, if your dataset contains images of dogs, you might add labels for breeds of dogs. 

After importing your images into a dataset, you might need to add labels to images or correct mislabeled images. For example, images aren't labeled if they are imported from a local computer. You use the dataset gallery to add new labels to the dataset and assign labels and bounding boxes to images in the dataset. 

How you label the images in your datasets determines the type of model that Amazon Rekognition Custom Labels trains. For more information, see [Purposing datasets](md-dataset-purpose.md). 

**Topics**
+ [

# Managing labels
](md-labels.md)
+ [

# Assigning image-level labels to an image
](md-assign-image-level-labels.md)
+ [

# Labeling objects with bounding boxes
](md-localize-objects.md)

# Managing labels


You can manage labels by using the Amazon Rekognition Custom Labels console. There isn't a specific API for managing labels – labels are added to the dataset when you create the dataset with `CreateDataset` or when you add more images to the dataset with `UpdateDatasetEntries`.

**Topics**
+ [

## Managing labels (Console)
](#md-labels-console)
+ [

## Managing Labels (SDK)
](#md-labels-sdk)

## Managing labels (Console)


You can use the Amazon Rekognition Custom Labels console to add, change, or remove labels from a dataset. To add a label to a dataset, you can add a new label that you create or import labels from an existing dataset in Rekognition.

**Topics**
+ [

### Add new labels (Console)
](#md-add-new-labels)
+ [

### Change and remove labels (Console)
](#md-edit-labels-after-adding)

### Add new labels (Console)


You can specify new labels that you want to add to your dataset. 

#### Add labels using the editing window


**To add a new label (console)**

1. Open the Amazon Rekognition console at [https://console.aws.amazon.com/rekognition/](https://console.aws.amazon.com/rekognition/).

1. Choose **Use Custom Labels**.

1. Choose **Get started**. 

1. In the left navigation pane, choose **Projects**.

1. In the **Projects** page, choose the project that you want to use. The details page for your project is displayed.

1. If you want to add labels to your training dataset, choose the **Training** tab. Otherwise choose the **Test** tab to add labels to the test dataset. 

1. Choose **Start labeling** to enter labeling mode.

1. In the **Labels** section of the dataset gallery, choose **Manage labels** to open the **Manage labels** dialog box.

1. In the edit box, enter a new label name.

1. Choose **Add label**.

1. Repeat steps 9 and 10 until you have created all the labels you need.

1. Choose **Save** to save the labels that you added.

### Change and remove labels (Console)


You can rename or remove labels after adding them to a dataset. You can only remove labels that are not assigned to any images.

**To rename or remove an existing label (console)**

1. Open the Amazon Rekognition console at [https://console.aws.amazon.com/rekognition/](https://console.aws.amazon.com/rekognition/).

1. Choose **Use Custom Labels**.

1. Choose **Get started**. 

1. In the left navigation pane, choose **Projects**.

1. In the **Projects** page, choose the project that you want to use. The details page for your project is displayed.

1. If you want to change or delete labels in your training dataset, choose the **Training** tab. Otherwise choose the **Test** tab to change or delete labels to the test dataset. 

1. Choose **Start labeling** to enter labeling mode.

1. In the **Labels** section of the dataset gallery, choose **Manage labels** to open the **Manage labels** dialog box.

1. Choose the label that you want to edit or delete.   
![\[Manage labels dialog box showing a text field to add a new label and an existing label named "test", with options to save or cancel changes.\]](http://docs.aws.amazon.com/rekognition/latest/customlabels-dg/images/change-delete-label.jpg)

   1. If you choose the delete icon (X), the label is removed from the list.

   1. If you want to change the label, choose the edit icon (pencil and paper pad) and enter a new label name in the edit box. 

1. Choose **Save** to save your changes.

## Managing Labels (SDK)


There isn't a unique API that manages dataset labels. If you create a dataset with `CreateDataset`, the labels found in the manifest file or copied dataset, create the initial set of labels. If you add more images with the `UpdateDatasetEntries` API, new labels found in the entries are added to the dataset. For more information, see [Adding more images (SDK)](md-add-images.md#md-add-images-sdk). To delete labels from a dataset, you must remove all label annotations in the dataset.

**To delete labels from a dataset**

1. Call `ListDatasetEntries` to get the dataset entries. For example code, see [Listing dataset entries (SDK)](md-listing-dataset-entries-sdk.md).

1. In the file, remove any label annotations. For more information, see [Importing image-level labels in manifest files](md-create-manifest-file-classification.md) and [Object localization in manifest files](md-create-manifest-file-object-detection.md). 

1. Use the file to update the dataset with the `UpdateDatasetEntries` API. For more information, see [Adding more images (SDK)](md-add-images.md#md-add-images-sdk).

# Assigning image-level labels to an image


You use image-level labels to train models that classify images into categories. An image-level label indicates that an image contains an object, scene or concept. For example, the following image shows a river. If your model classifies images as containing rivers, you would add a *river* image-level label. For more information, see [Purposing datasets](md-dataset-purpose.md). 

![\[Lake reflecting mountains and clouds in still water at sunset or sunrise.\]](http://docs.aws.amazon.com/rekognition/latest/customlabels-dg/images/pateros.jpg)


A dataset that contains image-level labels, needs at least two labels defined. Each image needs at least one assigned label that identifies the object, scene, or concept in the image.

**To assign image-level labels to an image (console)**

1. Open the Amazon Rekognition console at [https://console.aws.amazon.com/rekognition/](https://console.aws.amazon.com/rekognition/).

1. Choose **Use Custom Labels**.

1. Choose **Get started**. 

1. In the left navigation pane, choose **Projects**.

1. In the **Projects** page, choose the project that you want to use. The details page for your project is displayed.

1. In the left navigation pane, choose **Dataset**. 

1. If you want to add labels to your training dataset, choose the **Training** tab. Otherwise choose the **Test** tab to add labels to the test dataset. 

1. Choose **Start labeling** to enter labeling mode.

1. In the image gallery, select one or more images that you want to add labels to. You can only select images on a single page at a time. To select a contiguous range of images on a page:

   1. Select the first image in the range.

   1. Press and hold the shift key.

   1. Select the last image range. The images between the first and second image are also selected. 

   1. Release the shift key.

1. Choose **Assign image-level labels**. 

1. In the **Assign image-level label to selected images** dialog box, select a label that you want to assign to the image or images.

1. Choose **Assign** to assign label to the image.

1. Repeat labeling until every image is annotated with the required labels.

1. Choose **Save changes** to save your changes.

## Assign image-level labels (SDK)


You can use the `UpdateDatasetEntries` API to add or update the image-level labels that are assigned to an image. `UpdateDatasetEntries` takes one or more JSON lines. Each JSON Line represents a single image. For an image with an image-level label, the JSON Line looks similar to the following. 

```
{"source-ref":"s3://custom-labels-console-us-east-1-nnnnnnnnnn/gt-job/manifest/IMG_1133.png","TestCLConsoleBucket":0,"TestCLConsoleBucket-metadata":{"confidence":0.95,"job-name":"labeling-job/testclconsolebucket","class-name":"Echo Dot","human-annotated":"yes","creation-date":"2020-04-15T20:17:23.433061","type":"groundtruth/image-classification"}}
```

The `source-ref` field indicates the location of the image. The JSON line also includes the image-level labels assigned to the image. For more information, see [Importing image-level labels in manifest files](md-create-manifest-file-classification.md).

**To assign image-level labels to an image**

1. Get the get JSON Line for the existing image by using the `ListDatasetEntries`. For the `source-ref` field, specify the location of the image that you want to assign the label to. For more information, see [Listing dataset entries (SDK)](md-listing-dataset-entries-sdk.md). 

1. Update the JSON Line returned in the previous step using the information at [Importing image-level labels in manifest files](md-create-manifest-file-classification.md).

1. Call `UpdateDatasetEntries` to update the image. For more information, see [Adding more images to a dataset](md-add-images.md).

# Labeling objects with bounding boxes


If you want your model to detect the location of objects within an image, you must identify what the object is and where it is in the image. A bounding box is a box that isolates an object in an image. You use bounding boxes to train a model to detect different objects in the same image. You identify the object by assigning a label to the bounding box. 

**Note**  
If you're training a model to find objects, scenes, and concepts with image-level labels, you don't need to do this step.

For example, if you want to train a model that detects Amazon Echo Dot devices, you draw a bounding box around each Echo Dot in an image and assign a label named *Echo Dot* to the bounding box. The following image shows a bounding box around an Echo Dot device. The image also contains an Amazon Echo without a bounding box.

![\[Amazon Echo Dot and Echo devices, with bounding box around Echo Dot.\]](http://docs.aws.amazon.com/rekognition/latest/customlabels-dg/images/dot.jpg)


## Locate objects with bounding boxes (Console)


 In this procedure, you use the console to draw bounding boxes around the objects in your images. You also can identify objects within the image by assigning labels to the bounding box. 

**Note**  
You can't use the Safari browser to add bounding boxes to images. For supported browsers, see [Setting up Amazon Rekognition Custom Labels](setting-up.md).

Before you can add bounding boxes, you must add at least one label to the dataset. For more information, see [Add new labels (Console)](md-labels.md#md-add-new-labels).

****

**To add a bounding boxes to images (console)**

1. Open the Amazon Rekognition console at [https://console.aws.amazon.com/rekognition/](https://console.aws.amazon.com/rekognition/).

1. Choose **Use Custom Labels**.

1. Choose **Get started**. 

1. In the left navigation pane, choose **Projects**.

1. In the **Projects** page, choose the project that you want to use. The details page for your project is displayed.

1. On the project details page, choose **Label images**

1. If you want to add bounding boxes to your training dataset images, choose the **Training** tab. Otherwise choose the **Test** tab to add bounding boxes to the test dataset images. 

1. Choose **Start labeling** to enter labeling mode.

1. In the image gallery, choose the images that you want to add bounding boxes to.

1. Choose **Draw bounding box**. A series of tips are shown before the bounding box editor is displayed.

1. In the **Labels** pane on the right, select the label that you want to assign to a bounding box.

1. In the drawing tool, place your pointer at the top-left area of the desired object.

1. Press the left mouse button and draw a box around the object. Try to draw the bounding box as close as possible to the object. 

1. Release the mouse button. The bounding box is highlighted.

1. Choose **Next** if you have more images to label. Otherwise, choose **Done** to finish labeling.  
![\[UI to draw bounding box around an image, the image is Amazon Echo and Echo Dot smart speakers on a wooden surface.\]](http://docs.aws.amazon.com/rekognition/latest/customlabels-dg/images/draw-bounding-box.png)

1. Repeat steps 1–7 until you have created a bounding box in each image that contains objects. 

1. Choose **Save changes** to save your changes. 

1. Choose **Exit** to exit labeling mode.

## Locate objects with bounding boxes (SDK)


You can use the `UpdateDatasetEntries` API to add or update object location information for an image. `UpdateDatasetEntries` takes one or more JSON lines. Each JSON Line represents a single image. For object localization, a JSON Line looks similar to the following. 

```
{"source-ref": "s3://bucket/images/IMG_1186.png", "bounding-box": {"image_size": [{"width": 640, "height": 480, "depth": 3}], "annotations": [{ "class_id": 1,	"top": 251,	"left": 399, "width": 155, "height": 101}, {"class_id": 0, "top": 65, "left": 86, "width": 220,	"height": 334}]}, "bounding-box-metadata": {"objects": [{ "confidence": 1}, {"confidence": 1}],	"class-map": {"0": "Echo",	"1": "Echo Dot"}, "type": "groundtruth/object-detection", "human-annotated": "yes",	"creation-date": "2013-11-18T02:53:27", "job-name": "my job"}}
```

The `source-ref` field indicates the location of the image. The JSON line also includes labeled bounding boxes for each object on the image. For more information, see [Object localization in manifest files](md-create-manifest-file-object-detection.md).

**To assign bounding boxes to an image**

1. Get the get JSON Line for the existing image by using the `ListDatasetEntries`. For the `source-ref` field, specify the location of the image that you want to assign the image-level label to. For more information, see [Listing dataset entries (SDK)](md-listing-dataset-entries-sdk.md).

1. Update the JSON Line returned in the previous step using the information at [Object localization in manifest files](md-create-manifest-file-object-detection.md).

1. Call `UpdateDatasetEntries` to update the image. For more information, see [Adding more images to a dataset](md-add-images.md).