Costume Background Removal
curl --request POST \
--url https://www.ailabapi.com/api/cutout/general/apparel-background-removal \
--header 'Content-Type: multipart/form-data' \
--header 'ailabapi-api-key: <api-key>' \
--form image='@example-file' \
--form out_mode=0 \
--form 'cloth_class=tops,coat,skirt,pants,bag,shoes,hat'import requests
url = "https://www.ailabapi.com/api/cutout/general/apparel-background-removal"
files = { "image": ("example-file", open("example-file", "rb")) }
payload = {
"out_mode": "0",
"cloth_class": "tops,coat,skirt,pants,bag,shoes,hat"
}
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('image', '<string>');
form.append('out_mode', '0');
form.append('cloth_class', 'tops,coat,skirt,pants,bag,shoes,hat');
const options = {method: 'POST', headers: {'ailabapi-api-key': '<api-key>'}};
options.body = form;
fetch('https://www.ailabapi.com/api/cutout/general/apparel-background-removal', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.ailabapi.com/api/cutout/general/apparel-background-removal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.ailabapi.com/api/cutout/general/apparel-background-removal"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.ailabapi.com/api/cutout/general/apparel-background-removal")
.header("ailabapi-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.ailabapi.com/api/cutout/general/apparel-background-removal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ailabapi-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"request_id": "",
"log_id": "",
"error_detail": {
"code": "",
"code_message": "",
"message": ""
},
"data": {
"elements": [
{
"image_url": ""
},
{
"class_url": {
"tops": "",
"coat": "",
"skirt": "",
"pants": "",
"bag": "",
"shoes": "",
"hat": ""
}
}
]
}
}AI BACKGROUND REMOVAL > General
Costume Background Removal
Costume Background Removal API removes clothing backgrounds and isolates garments for apparel photos, e-commerce listings, and product displays.
POST
/
api
/
cutout
/
general
/
apparel-background-removal
Costume Background Removal
curl --request POST \
--url https://www.ailabapi.com/api/cutout/general/apparel-background-removal \
--header 'Content-Type: multipart/form-data' \
--header 'ailabapi-api-key: <api-key>' \
--form image='@example-file' \
--form out_mode=0 \
--form 'cloth_class=tops,coat,skirt,pants,bag,shoes,hat'import requests
url = "https://www.ailabapi.com/api/cutout/general/apparel-background-removal"
files = { "image": ("example-file", open("example-file", "rb")) }
payload = {
"out_mode": "0",
"cloth_class": "tops,coat,skirt,pants,bag,shoes,hat"
}
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('image', '<string>');
form.append('out_mode', '0');
form.append('cloth_class', 'tops,coat,skirt,pants,bag,shoes,hat');
const options = {method: 'POST', headers: {'ailabapi-api-key': '<api-key>'}};
options.body = form;
fetch('https://www.ailabapi.com/api/cutout/general/apparel-background-removal', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.ailabapi.com/api/cutout/general/apparel-background-removal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.ailabapi.com/api/cutout/general/apparel-background-removal"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.ailabapi.com/api/cutout/general/apparel-background-removal")
.header("ailabapi-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.ailabapi.com/api/cutout/general/apparel-background-removal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ailabapi-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"out_mode\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cloth_class\"\r\n\r\ntops,coat,skirt,pants,bag,shoes,hat\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"request_id": "",
"log_id": "",
"error_detail": {
"code": "",
"code_message": "",
"message": ""
},
"data": {
"elements": [
{
"image_url": ""
},
{
"class_url": {
"tops": "",
"coat": "",
"skirt": "",
"pants": "",
"bag": "",
"shoes": "",
"hat": ""
}
}
]
}
}Authorizations
API Key for authentication
Body
multipart/form-data
- Image format:
JPEGJPGBMPPNG. - Image size: No more than 5 MB.
- Image resolution: Larger than 50x50px and smaller than 3000x3000px.
Specifies the type of segmentation result to return, which affects the content of the image_url field.
0: Default segmentation result of the main clothing.1: Combined segmentation result based on the category specified bycloth_class.
Available options:
0, 1 Clothing categories. Multiple values can be submitted at once, separated by commas (,).
tops: Tops.coat: Coat.skirt: Skirt.pants: Pants.bag: Bag.shoes: Shoes.hat: Hat.
Example:
"tops,coat,skirt,pants,bag,shoes,hat"
Specify the desired image format for the output.
whiteBK: Returns an image with a white background.mask: Returns a single-channel mask.- If not specified, a four-channel PNG image will be returned.
Available options:
mask, whiteBK ⌘I

