Skip to content

AI Photo Background Removal

Overview

Remove background from photo with impeccable accuracy, ensuring the high quality of images.

  • Automatic Background Detection: : Uses AI to identify and separate the subject from the background.
  • High Precision Editing: : Provides clean and precise edges around the subject.
  • Supports various categories: People, Products, Animals, Cars, Graphics & more.
  • Easy to chain with other AI tasks: The output file ID can be chained into other AI tasks in a flash.

Integration Guide

  • How to run AI Photo Background Removal
  1. Resize your source image
    Resize your photo to fit the supported dimensions. See details in File Specs & Errors

  2. Upload file using the File API
    Using the /s2s/v2.0/file API to upload a target user image.

    • Image Requirements

    • Important: Simply calling the File API does not upload your file. You must manually upload the file to the URL provided in the File API response. That URL is your upload destination, make sure the file is successfully transferred there before proceeding.
      Before calling the AI API, ensure your file has been successfully uploaded. Use the File API to retrieve an upload URL, then upload your file to that location. Once the upload is complete, you'll receive a file_id in the response, this ID is what you'll use to access AI features related to that file.

      Warning: Please note that, you will get an 500 Server Error / unknown_internal_error or 404 Not Found error when using AI APIs if you do not upload the file to the URL provided in the File API response.

  3. Run an AI task
    Once the upload is complete, calling POST 'task/sod' with the File ID to execute the AI task and obtains a task_id to monitor.

  4. Polling to check the status of a task until it succeed or error
    This task_id is used to monitor the task's status through polling GET 'task/sod' to retrieve the current engine status. Until the engine completes the task, the status will remain 'running', and no units will be consumed during this stage.

    Warning: Please note that, Polling to check the status of a task based on it's polling_interval is mandotary. A task will be timed out if there is no polling request within the polling_interval, even if the task is processed succefully(Your unit(s) will be consumed).

    Warning: You will get a InvalidTaskId error once you check the status of a timed out task. So, once you run an AI task, you need to polling to check the status within the polling_interval until the status become either success or error.

  5. Get the result of an AI task once success
    The task will change to the 'success' status after the engine successfully processes your input file and generates the resulting image. You will get an url of the processed image and a dst_id that allow you to chain another AI task without re-upload the result image. Your units will only be consumed in this case. If the engine fails to process the task, the task's status will change to 'error' and no unit will be consumed.
    When deducting units, the system will prioritize those nearing expiration. If the expiration date is the same, it will deduct the units obtained on the earliest date.

  • Demonstrative scenarios: Common implementation cases:

Inputs & Outputs

  • Inputs
    • Image
  • Type: image
  • Description: An image with clear foreground.

Real-world application (input):


  • Outputs
    • Foreground image
  • Type: image
  • Description: A background removed image.

Real-world application (output):

File Specs & Errors

  • Supported Formats & Dimensions
AI FeatureSupported DimensionsFile SizeAccepted formats
AI Photo Background RemovalRecommendations and limitations for both input and output images are as follows:
Resolution: 4096 × 4096 pixels (longest side must not exceed 4096 pixels)
<10MBJPG and PNG
  • Error Codes
Error CodeDescription
exceed_max_filesizeInput file size exceeds the maximum limit
invalid_parameterInvalid parameter value
error_download_imageDownload source image error
error_download_maskDownload mask image error
error_decode_imageDecode source image error
error_decode_maskDecode mask image error
error_download_videoDownload source video error
error_decode_videoDecode source video error
error_nsfw_content_detectedNSFW content detected in source image
error_no_faceNo face detected on source image
error_poseFailed to detect pose on source image
error_face_parsingFailed to do face segmentation on source image
error_inferenceInference pipeline error
exceed_nsfw_retry_limitsExceed the retry limits to avoid generated NSFW image
error_uploadUpload result image error
error_multiple_peopleMultiple people detected in the source image
error_no_shoulderShoulders are not visible in the source image
error_large_face_angleThe face angle in the uploaded image is too large
error_hair_too_shortInput hair is too short
error_unexpected_video_durationVideo durateion is not equal to the dstDuration
error_bald_imageInput hairstyle is bald
error_unsupport_ratioThe aspect ratio of input image is unsupported
unknown_internal_errorOthers

Unit Consumption

AI FeatureUnit Consumed
AI Photo Background Removal V1.01

Languages
Servers
https://yce-api-01.makeupar.com