---
title: "Label objects in an image"
section: "frontend/predictions"
platforms: ["angular", "javascript", "nextjs", "react", "react-native", "vue"]
gen: 2
last-updated: "2026-03-25T17:40:00.000Z"
url: "https://docs.amplify.aws/react/frontend/predictions/label-image/"
---

export async function getStaticPaths() {
  return getCustomStaticPath(meta.platforms);
}

<Callout informational>

**Note:** Make sure to complete the [getting started](/[platform]/build-a-backend/add-aws-services/predictions/set-up-predictions/) section first, where you will set up the IAM roles with the right policy actions

</Callout>

## Working with the API

Detect labels, such if an image has a desk or a chair in it

```javascript
import { Predictions } from '@aws-amplify/predictions';

Predictions.identify({
  labels: {
    source: {
      file
    },
    type: 'LABELS'
  }
})
  .then((response) => {
    const { labels } = response;
    labels.forEach((object) => {
      const { name, boundingBoxes } = object;
    });
  })
  .catch((err) => console.log({ err }));
```

Detect unsafe content in an image

```ts
import { Predictions } from '@aws-amplify/predictions';

const { unsafe } = await Predictions.identify({
  labels: {
    source: {
      file
    },
    type: 'UNSAFE'
  }
})
```

For both labels and unsafe content

```ts
import { Predictions } from '@aws-amplify/predictions';

const { labels, unsafe } = await Predictions.identify({
  labels: {
    source: {
      file
    },
    type: 'ALL'
  }
})
```
