Skip to main content

Face Generator Endpoint

Overview

This endpoint allows you to generate image with the face image provided

Open in Playground 🚀
Face gen endpoint result

caution

Image url generated will not be accessible after 24 hours, kindly save your image generations accordingly

Request

--request POST 'https://modelslab.com/api/v6/image_editing/face_gen' \

Make a POST request to https://modelslab.com/api/v6/image_editing/face_gen endpoint and pass the required parameters as a request body to the endpoint.

Body Attributes

ParameterDescriptionValues
keyYour API Key used for request authorizationstring
promptThe text prompt describing the content you want in the generated imagestring
face_imageA link or valid base64 data of the face you want your generations to resemble. The format should be data:image/jpeg;base64,{your_base64_string}URL or base64 string
widthThe width of the generated image. The maximum dimension is 512 x 768 pixelsinteger (max: 512)
heightThe height of the generated image. The maximum dimension is 512 x 768 pixelsinteger (max: 768)
num_inference_stepsThe number of denoising steps. The acceptable values are 21, 31, or 41integer (21, 31, or 41)
guidance_scaleThe scale for classifier-free guidance. The minimum is 1 and the maximum is 20integer (1 to 20)
s_scaleAdjust the weight of the face structure. This should be a float between 0.0 and 2.0. The default is 1.0float (0.0 to 2.0) (default: 1.0)
samplesThe number of images to be returned in response. The maximum value is 2. Note: For resolutions such as 512x768 one sample will be generated, even if the samples value is set to 2.integer (max: 2)
safety_checkerWhether to run the safety checker to prevent NSFW image generation. This should be either true or falseboolean (true or false)
safety_checker_typeThe type of safety checker to use. Must be one of black, blur, sensitive_content_text, or pixelatestring (black, blur, sensitive_content_text, pixelate)
base64Set to true if the provided face image is in base64 format or if you want your generated images as a base64 string. The default is falseboolean (true or false) (default: false)
style This is required to generate output image in particular style. Default value is realistic.Options comic, chibi,3d, anime and realistic
webhookProvide a URL to receive a POST API call once the image generation is completeURL
track_idThis ID is returned in the response to the webhook API call and will be used to identify the webhook requestintegral value

Example

Body

Body
{
"key": "",
"prompt": "pretty woman",
"negative_prompt": "anime, cartoon, drawing, big nose, long nose, fat, ugly, big lips, big mouth, face proportion mismatch, unrealistic, monochrome, lowres, bad anatomy, worst quality, low quality, blurry",
"face_image":"https://media.allure.com/photos/647f876463cd1ef47aab9c88/3:2/w_2465,h_1643,c_limit/angelina%20jolie%20blonde%20hair%20chloe.jpg",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "21",
"safety_checker": false,
"base64": false,
"seed": null,
"guidance_scale": 7.5,
"webhook": null,
"track_id": null

}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key": "",
"prompt": "pretty woman",
"negative_prompt": "anime, cartoon, drawing, big nose, long nose, fat, ugly, big lips, big mouth, face proportion mismatch, unrealistic, monochrome, lowres, bad anatomy, worst quality, low quality, blurry",
"face_image":"https://media.allure.com/photos/647f876463cd1ef47aab9c88/3:2/w_2465,h_1643,c_limit/angelina%20jolie%20blonde%20hair%20chloe.jpg",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "21",
"safety_checker": false,
"base64": false,
"seed": null,
"guidance_scale": 7.5,
"webhook": null,
"track_id": null
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://modelslab.com/api/v6/image_editing/face_gen", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response

{
"status": "success",
"generationTime": 7.358475685119629,
"id": 32,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/temp/8c3ef6ea-1c44-4d69-91cb-fc11971a65d1-0.png"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/temp/8c3ef6ea-1c44-4d69-91cb-fc11971a65d1-0.png"
],
"meta": {
"base64": "no",
"face_image": "https://media.allure.com/photos/647f876463cd1ef47aab9c88/3:2/w_2465,h_1643,c_limit/angelina%20jolie%20blonde%20hair%20chloe.jpg",
"file_prefix": "8c3ef6ea-1c44-4d69-91cb-fc11971a65d1",
"guidance_scale": 7.5,
"height": 512,
"negative_prompt": "anime, cartoon, drawing, big nose, long nose, fat, ugly, big lips, big mouth, face proportion mismatch, unrealistic, monochrome, lowres, bad anatomy, worst quality, low quality, blurry",
"num_inference_steps": 21,
"outdir": "out",
"prompt": "pretty woman",
"safety_checker": "no",
"safety_checker_type": "blur",
"samples": 1,
"seed": 4029484891,
"temp": "yes",
"width": 512
}
}