🧭

InstantID - One-shot personalization without fine-tuning

image
image

[POST] https://api.nichetensor.com/api/v1/instantid

  • Header
NAME
TYPE
REQUIRED
API_KEY
string
✔️
  • Body
NAME
TYPE
REQUIRED
DESCRIPTION
Available Choices
prompt
string
✔️
The textual prompt used to generate the image.
model_name
string
✔️
The name of the model to use for this pipeline
DreamShaperXL
conditional_image
string
✔️
The base64 encoded image, must contains person face
seed
integer
The seed value for the random number generator. Use 0 for a random seed. Default: 0.
advanced_params.use_expansion
bool
Use prompt expansion for more aesthetic output
True, False
  • Example Request
import requests
from PIL import Image
import base64
import io

def pil_image_to_base64(image: Image.Image, format="JPEG") -> str:
    if format not in ["JPEG", "PNG"]:
        format = "JPEG"
    image_stream = io.BytesIO()
    image.save(image_stream, format=format)
    base64_image = base64.b64encode(image_stream.getvalue()).decode("utf-8")
    return base64_image

endpoint = "https://api.nichetensor.com/api/v1/instantid"
headers = {"API_KEY": "your_api_key"}


image = Image.open("your_portrait.jpg")
base64_image = pil_image_to_base64(image)
 
data = {
    "prompt": "ghibli studio, animated, soft color, detailed, textured",
    "model_name": "DreamShaperXL",
    "conditional_image": base64_image,
    "seed": 0,
}
 
response = requests.post(endpoint, json=data, headers=headers)
 
print(response.status_code)
print(response.json())
  • Example Response
{
		"image": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4n" # base64 image
}