Remove Background

Changed on

Remove background from the given image.

post/background-removal

Request

Request body

alpha_mattingboolean nullable

True to use alpha matting. May be true only only for rembg driver.

alpha_matting_background_thresholdinteger nullable

Background threshold for alpha matting. Applies only when alpha_matting is true.

alpha_matting_erode_sizeinteger nullable

Erosion size for alpha matting. Applies only when alpha_matting is true.

alpha_matting_foreground_thresholdinteger nullable

Foreground threshold for alpha matting. Applies only when alpha_matting is true.

driverstring nullable

Identifies the background removal technique to use. Valid options are rembg or birefnet.

init_imagestring nullable

Input image to modify.

init_image_urlstring nullable

If given, download init_image from this URL.

modelstring nullable

Identifies the model to use for background removal. Valid values depend on the value of the "driver" field. When driver is "birefnet," model must be "birefnet-dis-epoch540." When driver is "rembg," model must be "isnet-general-use", "u2net", "u2netp", "u2net_human_seg", or "u2net_cloth_seg."

only_maskboolean nullable

Flag indicating whether to return only the binary masks.

output_image_encoding'png'

Define which encoding process should be applied before returning the modified image. Only png is accepted.

post_process_maskboolean nullable

Flag indicating whether to post-process the masks. Applies only when driver is rembg; ignored otherwise.

Example request

{
  "output_image_encoding": "png"
}

Response

Successful Response

image_b64string nullable required

The modified image or None if it was removed for safety.

removed_for_safetyboolean required

True if the image was removed for safety, False otherwise.

Changes

    • breaking

      request property was restricted to a list of enum values

    • breaking

      the request property type changed from no type to string

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new png enum value to the request property