1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const axios = require('axios');
const FormData = require('form-data');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/face-to-sticker";
const reqBody = {
"seed": 411,
"image": "https://segmind-sd-models.s3.amazonaws.com/display_images/face-to-sticker-input.jpg",
"steps": 20,
"width": 1024,
"height": 1024,
"prompt": "a person",
"upscale": false,
"upscale_steps": 10,
"prompt_strength": 7,
"ip_adapter_noise": 0.5,
"ip_adapter_weight": 0.2,
"instant_id_strength": 1
};
(async function() {
try {
const formData = new FormData();
// Append regular fields
for (const key in reqBody) {
if (reqBody.hasOwnProperty(key)) {
formData.append(key, reqBody[key]);
}
}
// Convert and append images as Base64 if necessary
const response = await axios.post(url, formData, {
headers: {
'x-api-key': api_key,
...formData.getHeaders()
}
});
console.log(response.data);
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
}
})();
Fix the random seed for reproducibility
An image of a person to be converted to a sticker
2x upscale the sticker
Number of steps to upscale
Things you do not want in the image
Strength of the prompt. This is the CFG scale, higher numbers lead to stronger prompt, lower numbers will keep more of a likeness to the original.
How much noise is added to the IP adapter input
min : 0,
max : 1
How much the IP adapter will influence the image
min : 0,
max : 1
How strong the InstantID will be.
min : 0,
max : 1
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Face to sticker model takes an image of a person and creates a sticker image. This is based on style transfer, where essentially the sticker style is created for an input image of a person. The output is a new image that looks like a sticker but retains the facial features of the person in the input image. This model helps in the creation of personalized stickers from just about any image of a person.
Under the hood of Face to sticker model is a combination of Instant ID + IP Adapter + ControlNet Depth + Background removal.
Instant ID is responsible for identifying the unique features of the face of the person in the input image.
An image encoder (IP Adapter) helps in transferring the sticker style on to the face image of the person in the input image.
ControlNet Depth estimates the depth of different parts of the face. This helps in creating a 3D representation of the face, which can then be used to apply the sticker style in a way that looks natural and realistic.
Background Removal removes the background, resulting in a clean sticker image.
Input image: Choose an image that you want to transform into a sticker. A close-up portrait shot is ideal because it allows the model to clearly identify and process the facial features.
Prompt: Provide a text prompt based on the input image. This could be a simple description of the person in the image, such as “a man” etc. The model uses this prompt to guide the style transfer process.
Parameters: Adjust the below parameters to guide the final image output.
a. Prompt Strength: This parameter is similar to the CGF scale. It determines how closely the image generation follows the text prompt. A higher value will result in an output image that more closely matches the prompt.
b. IP Adapter Noise: This parameter determines the degree of influence of the sticker style. A higher value will result in a more stylized output image
c. IP Adapter Strength: This parameter determines the weight of influence of the sticker style. A higher value will result in a stronger application of the sticker style to the output image.
d. Instant ID strength: This parameter determines how closely the output image resembles the person in the input image. A higher value will result in an output image that more closely resembles the input image.