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
import requests
api_key = "YOUR_API_KEY"
url = "https://api.segmind.com/v1/pulid-base"
# Prepare data and files
data = {}
files = {}
data['seed'] = 451312
data['width'] = 1024
data['height'] = 1024
data['prompt'] = "anime middle aged professional guy"
# For parameter "face_image", you can send a raw file or a URI:
# files['face_image'] = open('IMAGE_PATH', 'rb') # To send a file
# data['face_image'] = 'IMAGE_URI' # To send a URI
data['face_style'] = "high-fidelity"
data['output_format'] = "png"
data['output_quality'] = 80
data['negative_prompt'] = "None"
data['checkpoint_model'] = "general - dreamshaperXL_alpha2Xl10"
data['number_of_images'] = 1
headers = {'x-api-key': api_key}
response = requests.post(url, data=data, files=files, headers=headers)
print(response.content) # The response is the generated image
Set a seed for reproducibility. Random by default.
Width of the output image (ignored if structure image given)
Height of the output image (ignored if structure image given)
You might need to include a gender in the prompt to get the desired result
The face image to use for the generation
An enumeration.
Allowed values:
An enumeration.
Allowed values:
Quality of the output images, from 0 to 100. 100 is best quality, 0 is lowest quality.
min : 0,
max : 100
Things you do not want to see in your image
An enumeration.
Allowed values:
Number of images to generate
min : 1,
max : 10
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.
Pure and Lightning ID customization (PuLID) is a novel tuning-free ID customization method for text-to-image generation. By incorporating a Lightning T2I branch with a standard diffusion one, PuLID introduces both contrastive alignment loss and accurate ID loss, minimizing disruption to the original model and ensuring high ID fidelity.
Experiments show that PuLID achieves superior performance in both ID fidelity and editability. Another attractive property of PuLID is that the image elements (e.g., background, lighting, composition, and style) before and after the ID insertion are kept as consistent as possible.