Skip to main content

Human Image Detection API Details

This document applies only to the China (Beijing) region. Use an API key from this region.

Human image detection

Supported realm/task: aigc/facechain portrait generation
This service detects faces in uploaded images to determine whether they meet the standards for FaceChain fine-tuning. The detection analyzes multiple dimensions, such as face count, size, angle, lighting, and definition. The service supports image groups as input and returns a detection result for each image. This model is an optional step in the task flow. You can integrate it as needed.

Image selection recommendations

  1. Face count: Each image must contain only one face. Images with multiple faces or no faces are not supported.
  2. Face quality: The image must contain a frontal face that is larger than 128 × 128 pixels and not blocked by objects, such as sunglasses or hands. Avoid heavy makeup and excessive retouching.
  3. Image quality: The image resolution must be between 256 × 256 pixels and 4096 × 4096 pixels. The file size cannot exceed 5 MB. The image must be clear and free of complex lighting and shades.
20231030192317.jpg

Model overview

Model name

Model description

facechain-facedetect

Detects faces in uploaded images to check if they meet the standards for FaceChain fine-tuning. The detection analyzes multiple dimensions, including face count, size, angle, lighting, and definition. It supports image groups as input and returns a detection result for each image.

HTTP API

Feature description

This model provides a synchronous API. After you submit a job, the results are returned in the response.

Prerequisites

API limit: A single account, including an Alibaba Cloud account and its RAM users, is limited to 5 queries per second (QPS) for the job submission API.

Job submission API call

POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/vision/facedetection/detect Replace {WorkspaceId} with your actual workspace ID.

Request parameters

Parameter PassingFieldTypeRequiredDescriptionExample
HeaderContent-TypeStringYesRequest type: application/jsonapplication/json
AuthorizationStringYesAPI key. Example: Bearer d1**2aBearer d1**2a
BodymodelStringYesThe model to call. This is a fixed value.facechain-facedetect
input.imagesArrayYesThe input image URL. The resolution must be no less than 256256 and no greater than 40964096, the file size cannot exceed 5 MB, and supported formats include JPEG, PNG, JPG, and WEBP.The URL must be a publicly accessible address that supports the HTTP or HTTPS protocol. You can also obtain a temporary public URL here.

If the image URL contains non-ASCII characters (such as Chinese file names), you must first encode the URL (percent-encoding). Otherwise, an

InternalError.Algo

error may occur. For example, in Python, use

urllib.parse.quote()

, and in JavaScript, use

encodeURI()

to encode the URL.

"images": [ "http://a/a.jpg","http://b/b.jpg","http://c/c.jpg",]

Response parameters

Field

Type

Description

Example

output.is_face

Array

The detection results for the list of submitted images. The results correspond to the input images in order.

  • true: The detection passed.

  • false: The detection failed.

"is_face":[

true,

true,

false,

false

]

output.failed_reason

Array

The reason why the image detection failed.

no face detected

usage

Object

The billing usage statistics for this request. The facechain-facedetect model is currently free for a limited time, so the usage information is empty.

-

request_id

String

The unique system code for this request.

7574ee8f-38a3-4b1e-9280-11c33ab46e51

Request example

The following example shows a cURL command script that you can use to call this model.
Replace your-dashscope-api-key in the example with your API key to ensure that the code runs correctly.
curl --location --request POST 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/vision/facedetection/detect' \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{
  "model": "facechain-facedetect",
  "input": {
    "images": [
      "http://finetune-swap-wulanchabu.oss-cn-wulanchabu.aliyuncs.com/zhicheng/tmp/1E1D5AFA-3C3A-4B6F-ABD6-8742CA983C42.png",
      "http://finetune-swap-wulanchabu.oss-cn-wulanchabu.aliyuncs.com/zhicheng/tmp/3.JPG",
      "http://finetune-swap-wulanchabu.oss-cn-wulanchabu.aliyuncs.com/zhicheng/tmp/F2EA3984-6EE2-44CD-928F-109B7276BCB6.png"
    ]
  },
  "parameters": {
  }
}'

Response example

{
  "output": {
    "is_face": [true, false, true],
    "failed_reason": ["", "no face detected", ""]
  },
  "usage": {},
  "request_id": "549e0573-f630-9c17-8df2-08f605b4a646"
}

Error response example

If an error occurs during a job submission request, the response includes the code and message fields to indicate the cause of the error.
{
    "code":"InvalidApiKey",
    "message":"Invalid API-key provided.",
    "request_id":"fb53c4ec-1c12-4fc4-a580-cdb7c3261fc1"
}

Status codes

For information about the common status codes for the Large Model Service Platform, see Error Messages.

HTTP return code*

Error code (code)

Error message (message)

Description

400

InvalidParameter

Required parameter(s) missing or invalid, please check the request parameters.

The API call parameters are invalid.

500

InternalError.Algo

InternalError.Algo

An internal algorithm execution error occurred in the service. A common cause is that the input image URL contains non-ASCII characters (such as Chinese). Encode the URL and try again.