Remove people, objects, text, or watermarks from an image and fill in the erased area
image-erase-completion removes one or more elements from an image, such as people, pets, objects, text, or watermarks, and fills in the erased area while preserving the background. You mark the area to erase with a mask image.
Quick links: API reference: Create a task, Query the result
Supported regions: China North 2 (Beijing) only. Use an API key created in that region and the https://cn-beijing.maas.qwencloudapi.com endpoint. See Regions and endpoints.
The model is available for free trial only. After the free quota is used, calls are no longer possible. As an alternative, use Image editing.
Image requirements
| Image | Requirements |
|---|---|
| Input image | JPEG, PNG, JPG, BMP, or WEBP; width and height between 512 and 4,096 pixels; up to 10 MB |
| Mask image | JPG, JPEG, PNG, HEIF, or WEBP; same resolution limits as the input image. Non-zero pixels mark the area to erase. |
| Foreground image (optional) | JPG, JPEG, PNG, HEIF, or WEBP; same resolution limits as the input image. Non-zero pixels mark the area to preserve. |
How it works
- Create a task: Send the input image, the mask image, and optional parameters. The API returns a
task_id. - Query the result: Poll
GET /tasks/{task_id}untiltask_statusisSUCCEEDED, then download the result image fromoutput.results[].url.
Request example
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
image_url | string | Yes | Input image URL or Base64-encoded image. |
mask_url | string | Yes | Mask image URL or Base64-encoded image. Non-zero pixels mark the area to erase. |
foreground_url | string | No | Foreground image URL or Base64-encoded image. Non-zero pixels mark the area to preserve. |
fast_mode | boolean | No | Enables fast mode. Inference takes about one quarter of the standard time, with less detail. Default: false. |
dilate_flag | boolean | No | Expands the mask before erasing. Set to true when the mask is generated by an algorithm and to false when you paint it manually. Default: true. |
add_watermark | boolean | No | Adds a "Generated by AI" watermark to the bottom-left corner of the output image. Default: true. |
FAQ
How do I erase a person?
Run Person instance segmentation on the image, use its mask image as mask_url, and set dilate_flag to true.
How long is the result URL valid?
24 hours after the task succeeds. Download the image promptly.
How is the model billed?
Billing is based on successfully generated images. A failed task is not billed. The model is currently free trial only.