# Generate Mask

> Describe a subject in plain words, such as "the red car", and get a black-and-white mask of it to repaint only that area in an editing node.

Source: https://nodaro.ai/docs/nodes/image/generate-mask

The **Generate Mask** node finds a subject in an image from a text description and returns a black-and-white mask of it. You write a short phrase such as "the red car", and the node marks that subject in white and everything else in black. Wire the mask into an editing node to repaint only that area.

- Found in: Image › Edit & Retouch
- Output: image
- API type: `generate-mask`

## When to use it
- Change one subject and keep the rest: mask "the jacket", then recolor it in [Modify Image](https://nodaro.ai/docs/nodes/image/modify-image).
- Replace what is behind the subject: mask "the background" and repaint it.
- Start a precise hand-made mask: generate one first, then refine it in [Paint Mask](https://nodaro.ai/docs/nodes/image/paint-mask).
- Select an area for [Relight & Switch](https://nodaro.ai/docs/nodes/video/relight-and-switch) or any other node with a mask input.

## Quick start
### Add the node

Press Tab on the canvas and choose **Image › Edit & Retouch › Generate Mask**.

### Connect the image

Drag from an image node, such as [Upload Image](https://nodaro.ai/docs/nodes/image/upload-image) or [Generate Image](https://nodaro.ai/docs/nodes/image/generate-image), to the **Image** input.

### Describe the subject

Open the settings panel and write the subject under **Describe what to mask**, for example `the red car`.

### Run it and wire the mask

Click **Run**. The mask appears on the node. Wire the **Mask** output into the **Mask** input of an editing node, and the same image into that node's **Image** input. In [Modify Image](https://nodaro.ai/docs/nodes/image/modify-image), choose a model that supports masks, such as Ideogram Edit.

Workflow: Generate Mask passes the photo through together with a mask of the red car, and Modify Image repaints only that area.

- Upload Image → Generate Mask (image)
- Generate Mask → Modify Image (image + mask)

## Inputs
| Input | Accepts | What it does |
| --- | --- | --- |
| **Image** | Image nodes, such as Upload Image, Generate Image and Modify Image | The picture to find the subject in. Required. |

Generate Mask has two outputs:

| Output | What it carries |
| --- | --- |
| **Image** | The original image, unchanged. Use it to send the same image to the editing node together with the mask. |
| **Mask** | A black-and-white PNG the size of the image. White is the subject, the area to edit. Black is everything else, the area to keep. |

The mask is a plain PNG, so it also works anywhere an image is accepted, for example to preview it or to save it.

## Settings
| Setting | What it does |
| --- | --- |
| **Describe what to mask** | The subject to find, as a short phrase such as `the red car`, `the woman` or `the background`. Required, up to 500 characters. |
| **Detection threshold** | A slider from `0.05` to `0.95`, default `0.3`. The model that Generate Mask uses today ignores this value, so moving the slider does not change the mask. To change the result, change the prompt. |
| **Pre & post text** | Text that is always added before and after the prompt. It is hidden from people who use your workflow as an app. See [Prompt pre and post text](https://nodaro.ai/docs/concepts/prompt-pre-post-text). |

## How the mask is made

Generate Mask always uses one segmentation model, Grounded SAM. The model finds the subject your words name, then traces its exact outline. The model version is fixed, so the same image and the same prompt always give the same mask. There is no model to choose.

White means "edit" and black means "keep". [Paint Mask](https://nodaro.ai/docs/nodes/image/paint-mask) and the mask painter in [Modify Image](https://nodaro.ai/docs/nodes/image/modify-image) use the same rule, so a generated mask and a painted mask are interchangeable.

## Credits
Every run costs 50 credits, whatever the image size or the prompt. When no region matches the description, the run fails and the credits are refunded.

## Troubleshooting
**The run fails with "No region matched the mask prompt".** Nothing in the image matched your words. Your credits are refunded. Running the same prompt again fails the same way, so rewrite it as a shorter, plainer phrase, such as `the hat` instead of a long description.

**The mask is empty.** An all-black mask means the prompt was too general or the subject is not in the image. Name the subject more clearly, for example `the left girl's hair` instead of `hair`.

**The mask is almost right.** Wire the **Mask** output into the **Mask seed** input of a [Paint Mask](https://nodaro.ai/docs/nodes/image/paint-mask) node. Its painter opens with the generated mask, and you can add or erase areas by hand.

## Tips
- **Name one clear subject.** The model reads short noun phrases, such as `the woman` or `the red car`, far better than long clauses.
- **Keep the image and the mask together.** The **Image** output passes the original through, so one wire from each output reaches the editing node.
- **Do not use the slider to fix a mask.** **Detection threshold** has no effect today. Change the prompt, or refine the mask by hand.

## Frequently asked questions

### What does Generate Mask produce?

A black-and-white PNG the size of your image. White marks the subject you described, which is the area an editing node may change. Black marks everything else, which stays as it is.

### How many credits does Generate Mask cost?

50 credits per run, whatever the image size or the prompt. When no region matches your description, the run fails and the credits are refunded.

### What should I write in the prompt?

A short, plain phrase that names the subject, such as "the red car", "the woman" or "the left girl's hair". Short noun phrases work far better than long descriptive sentences.

### Why did Generate Mask find nothing?

The description did not match anything the model could find. Rewrite it as a shorter, plainer phrase. Running the same prompt again gives the same result.

### Can I fix a mask that is almost right?

Yes. Wire the Mask output into the Mask seed input of a Paint Mask node. The painter opens with the generated mask, and you add or erase areas by hand.
