Enterprise: Avatar Generator Endpoint
Overview
This endpoint allows you to generate image with the face image provided
Request
--request POST 'https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen' \
Make a POST
request to https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen endpoint and pass the required parameters as a request body to the endpoint.
Body Attributes
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
prompt | Text prompt with description of the things you want in the image to be generated. |
init_image | Link or valid base64 data which follows data:image/jpeg;base64,{your_base64_string} to the image of the face you want your generations to resemble. |
width | Width of your generated image. Max dimension: 512 x 768 |
height | Height of your generated image. Max dimension: 512 x 768 |
num_inference_steps | Number of denoising steps. Value accepted are 21,31 or 41 |
guidance_scale | Scale for classifier-free guidance. |
s_scale | adjust the weight of the face structure [float][0.0 to 2.0] [default 1.0]. |
samples | Number of images to be returned in response. The maximum value is 2. |
safety_checker | Whether to run the safety checker to prevent NSFW image generation. One of true or false. |
safety_checker_type | Must be one of black , blur , sensitive_content_text , pixelate |
pose_image | Image used for pose reference. |
identitynet_strength_ratio | Strength ratio for identity network. Values range between 0.0 and 1.0 |
adapter_strength_ratio | Strength ratio for the adapter. Values range between 0.0 and 1.0. Default 1.0 |
pose_strength | Strength of the pose reference.. Values range between 0.0 and 1.0. Default 0.4 |
canny_strength | Strength of the canny edge detection. Values range between 0.0 and 1.0. Default 0.3 |
controlnet_selection | Selection mode for control network. Default pose |
base64 | If provided init_image is in base64 format or if you want your generated images as a base64 string, must be set to true . Default: false . |
webhook | Set an URL to get a POST API call once the image generation is complete. |
track_id | This ID is returned in the response to the webhook API call. This will be used to identify the webhook request. |
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",
"init_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,
"identitynet_strength_ratio": 1.0,
"adapter_strength_ratio": 1.0,
"pose_strength": 0.4,
"canny_strength": 0.3,
"controlnet_selection":"pose",
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
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",
"init_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,
"identitynet_strength_ratio": 1.0,
"adapter_strength_ratio": 1.0,
"pose_strength": 0.4,
"canny_strength": 0.3,
"controlnet_selection":"pose",
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"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",
"init_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,
"identitynet_strength_ratio" => 1.0,
"adapter_strength_ratio" => 1.0,
"pose_strength" => 0.4,
"canny_strength" => 0.3,
"controlnet_selection" => "pose",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen',
'headers': {
'Content-Type': 'application/json'
},
body: 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",
"init_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,
"identitynet_strength_ratio": 1.0,
"adapter_strength_ratio": 1.0,
"pose_strength": 0.4,
"canny_strength": 0.3,
"controlnet_selection":"pose",
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen"
payload = json.dumps({
"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",
"init_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": None,
"guidance_scale": 7.5,
"identitynet_strength_ratio": 1.0,
"adapter_strength_ratio": 1.0,
"pose_strength": 0.4,
"canny_strength": 0.3,
"controlnet_selection":"pose",
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"key\": \"\",\r\n \"prompt\": \"pretty woman\",\r\n \"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\",\r\n \"init_image\":\"https://media.allure.com/photos/647f876463cd1ef47aab9c88/3:2/w_2465,h_1643,c_limit/angelina%20jolie%20blonde%20hair%20chloe.jpg\",\r\n \"width\": \"512\",\r\n \"height\": \"512\",\r\n \"samples\": \"1\",\r\n \"num_inference_steps\": \"21\",\r\n \"safety_checker\": false,\r\n \"base64\": false,\r\n \"seed\": null,\r\n \"guidance_scale\": 7.5,\r\n \"identitynet_strength_ratio\": 1.0,\r\n \"adapter_strength_ratio\": 1.0,\r\n \"pose_strength\": 0.4,\r\n \"canny_strength\": 0.3,\r\n \"controlnet_selection\":\"pose\",\r\n \"webhook\": null,\r\n \"track_id\": null\r\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v1/enterprise/image_editing/avatar_gen")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "{{token}}")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 7.358475685119629,
"id": 32,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/temp/35435593-31f4-4d50-80d8-8e91f1ad54b7-0.png"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/temp/35435593-31f4-4d50-80d8-8e91f1ad54b7-0.pngg"
],
"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
}
}