Skip to main content
POST
/
api
/
portrait
/
effects
/
face-fusion
Merge Portraits
curl --request POST \
  --url https://www.ailabapi.com/api/portrait/effects/face-fusion \
  --header 'Content-Type: multipart/form-data' \
  --header 'ailabapi-api-key: <api-key>' \
  --form 'source_similarity=<string>' \
  --form image_target=@example-file \
  --form image_template=@example-file
{
  "request_id": "",
  "log_id": "",
  "error_code": 0,
  "error_code_str": "",
  "error_msg": "",
  "error_detail": {
    "status_code": 200,
    "code": "",
    "code_message": "",
    "message": ""
  },
  "data": {
    "image": ""
  }
}

Request

  • URL: https://www.ailabapi.com/api/portrait/effects/face-fusion
  • Method: POST
  • Content-Type: multipart/form-data

Image requirements

FieldRequirements
image_targetImage format: JPEG JPG BMP PNG“, Image size: No more than 4 MB., Image resolution: Larger than 128x128px, smaller than 4096x4096px., Face pixel size: To ensure the fusion effect, it is recommended that the minimum value of the side length of the face box (square) in the image is not less than 200px., Face quality: The higher the face quality, the better the fusion effect., Factors affecting face quality include: occlusion of the five facial features, improper lighting (bright light, dark light, backlighting), excessive face angle (recommended yaw ≤ ±20°, pitch ≤ ±20°), etc., Black and white images are not supported.
image_templateImage format: JPEG JPG BMP PNG“, Image size: No more than 4 MB., Image resolution: Larger than 200x200px, smaller than 4096x4096px., Note that for special face materials, such as cartoon style images with large eyes, the original key point results will be deviated, and should be made accurate by dragging the position in the configuration tool. Most normal images are already very accurate and do not need to be adjusted., The pixel area of the face in the image should not be too small (at least 200x200px, too small to change the face will not be clear), nor too large (the pixel size of the face area and speed is positively correlated, too large will affect the server speed and increase costs)., Pay attention to the quality of the material, make sure the face is clear enough, there should be no noise caused by compression, otherwise it will reduce the quality of the face replacement result., For better results, the face of the material should be as positive as possible, with the highest yaw angle required (within plus or minus 10 degrees recommended), followed by the pitch angle (within plus or minus 20 degrees recommended), and the roll angle (within plus or minus 30 degrees).

Headers

FieldRequiredTypeDescription
ailabapi-api-keyYESstringApplication API KEY. Get API KEY

Body

FieldRequiredTypeScopeDescription
image_targetYESfileTarget image.
image_templateYESfileTemplate images.
source_similarityNOfloat[0, 1]0`: Consistent with the original template.`, 1: Maximum similarity with the target image.

Response

Response Field Handling Flow
  1. Handle Public Response Fields Parse and validate the Public Response Fields, checking the status code or response message to ensure the request is successful and error-free.
  2. Handle Business Response Fields If the Public Response Fields are valid and error-free, proceed with processing the business logic in the Business Response Fields.

Public Response Fields

Viewing Public Response Fields and Error Codes

Business Response Fields

FieldTypeDescription
dataobjectThe content of the result data returned.
+imagestringThe result image, returning the Base64 encoding of the image.

Response Example

{
  "request_id":     "",
  "log_id":         "",
  "error_code":     0,
  "error_msg":      "",
  "error_detail":   {
    "status_code":  200,
    "code":         "",
    "code_message": "",
    "message":      ""
  },
  "data":           {
    "image": ""
  }
}

Sample Code

👉 Online Experience 👈If you’d like to see the actual effects, please visit the experience page for a trial.

Authorizations

ailabapi-api-key
string
header
required

API Key for authentication

Body

multipart/form-data
image_target
file

Target image.

image_template
file

Template images.

source_similarity
string

Face similarity, where a higher numerical value indicates greater similarity. <li>0: Consistent with the original template.</li> <li>1: Maximum similarity with the target image.</li>

Response

200 - application/json

Success

The response is of type object.