Clothing Segmentation API

Try on PicWish

Segment clothing and portrait regions from an image and return grayscale mask results for selected semantic classes. Supports async and sync request modes for production integrations.

Result links are valid for 1 hour. Please download and store them promptly.

Authentication

Every API request must include your API Key in the X-API-KEY request header. Send it with each request exactly as shown in the examples and parameter descriptions.

X-API-KEY: YOUR_API_KEY

Create a clothing segmentation task

POST /api/tasks/visual/clothing-segmentation

Body Parameters

image_url string optional

Source image URL. Use either image_url or image_file. If this parameter is present, the other image source parameter must be empty.

one required
image_file file optional

Source image file as binary multipart data. Use either image_file or image_url. If this parameter is present, the other image source parameter must be empty.

For image upload requirements, see Guidelines and Limits #4.

sync string | number optional

Whether to wait for the result and return it immediately. Use 0 to return a task_id asynchronously, then fetch the result later with the task_id. Use 1 to wait and return the result synchronously. Results are kept for up to 1 hour.

detail_mode number optional

Segmentation detail mode. 1 = fine-grained regular (default). 2 = fine-grained ultra-high. Regular fine-grained segmentation is recommended if you do not need full clothing subdivision grayscale images.

output_type number optional

Output content. 1 = only merged grayscale masks with the same semantics (default). 2 = all subdivided grayscale masks with the same semantics packaged as a ZIP file, currently only for clothing. 3 = return both.

quality number optional

Segmentation quality. 1 = regular segmentation quality (default); 2 = high precision quality.

class_type number optional

Semantic classes to return. 1 = clothing parts only: clothes, tops, bottoms, dress, acc (default). 2 = fashion parts: clothes, tops, bottoms, dress, bag, shoes, acc. 3 = portrait parts: hair, face, head, body. 4 = return all: hair, face, head, clothes, tops, bottoms, dress, bag, shoes, acc, body, others.
hair = hair, face = face, head = head, clothes = clothes, shoes = shoes, bag = bag, acc = accessories, tops = tops, bottoms = bottoms, dress = dress, body = body, others = others.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Async clothing segmentation task ID returned after the task is created. Use it to query the result later.

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Clothing segmentation task ID.

data.created_at string

Task creation time as a Unix timestamp string.

data.processed_at string

Task processing start time as a Unix timestamp string.

data.completed_at string

Task completion time as a Unix timestamp string.

data.clothes_masks string

ZIP URL for subdivided clothing grayscale masks when returned. The URL is valid for 1 hour.

data.class_masks object

Result mask URLs or base64 data keyed by semantic class, such as acc, body, clothes, face, hair, others, and shoes.

data.output_type number

Returned output type.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.

Query clothing segmentation result

GET /api/tasks/visual/clothing-segmentation/{task_id}

Path Parameters

task_id string required

Clothing segmentation task ID returned after creating an async task. Use it to query the processing result.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Clothing segmentation task ID.

data.created_at string

Task creation time as a Unix timestamp string.

data.processed_at string

Task processing start time as a Unix timestamp string.

data.completed_at string

Task completion time as a Unix timestamp string.

data.clothes_masks string

ZIP URL for subdivided clothing grayscale masks when returned. The URL is valid for 1 hour.

data.class_masks object

Result mask URLs or base64 data keyed by semantic class, such as acc, body, clothes, face, hair, others, and shoes.

data.output_type number

Returned output type.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.

Guidelines and Limits

  1. Result links are valid for 1 hour. Please download and store them promptly.

  2. HTTP status 200 only means the HTTP request succeeded. Determine task success from status and data.state together.

  3. When passing URLs as parameters, follow URL encoding standards to avoid parameter parsing issues.

  4. Uploaded images must meet the following format, resolution, and file size limits.

    FormatResolutionFile size
    jpg, jpeg, bmp, png, webp, tiff, tif, bitmap, raw, rgb, jfif, lzwUp to 4096 x 4096Up to 20MB