POST
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 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/consistent-character-with-pose" # Request payload data = { "base_64": False, "custom_height": 1024, "custom_width": 1024, "face_image": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/ccpose_ip.png"), # Or use image_file_to_base64("IMAGE_PATH") "output_format": "png", "pose_image": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/cc_pose_img.png"), # Or use image_file_to_base64("IMAGE_PATH") "prompt": "A candid photo of a woman , wearing a blue denim shirt and matching jeans. light smile on her face", "quality": 95, "samples": 1, "seed": 2778725438, "use_input_img_dimension": True } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


base_64bool ( default: 1 )

Output as base64 encoded string


custom_heightint ( default: 1024 )

Custom height for output image

min : 64,

max : 4096


custom_widthint ( default: 1024 )

Custom width for output image

min : 64,

max : 4096


face_imageimage *

Face image


output_formatenum:str ( default: png )

Output image format

Allowed values:


pose_imageimage *

Pose image


promptstr *

Textual description for the image generation


qualityint ( default: 95 )

Image quality setting for output

min : 10,

max : 100


samplesint *

Number of images to generate

min : 1,

max : 4


seedint *

Random seed for generation


use_input_img_dimensionbool ( default: true )

Whether to use the input image's dimensions

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.

Consistent Character With Pose

Consistent Character lets you generate new images of a specific person with remarkable consistency. It takes just one reference image and a text description of the desired pose variations. The magic lies in its ability to seamlessly transfer the person's unique characteristics onto a new body in a different pose. Under the hood of Consistent Character model is a combination of IP Adapter Face and instant id and openpose controlnet for generating image with pose followed by upscaling.