Skip to main content

Controlnet Models SD-1.5

ControlNet is a technique for adding conditional control to text-to-image diffusion models. It allows users to specify conditions or constraints on the generated images, such as the presence of specific objects, the style of the artwork, or the overall composition of the image.

Tip
  • Controlnets can sometimes introduce artifacts into the generated images. Ensure you use negative prompts to remove these.
  • Use multi-controlnet for combining two different ideas

import requests
import json
url = "https://api.imagepipeline.io/sd/controlnet/v1"
headers = {
"API-Key": "Your API Key"
}
data = {
"prompt": "Snow White's face, best quality, extremely detailed",
"negative_prompt": "monochrome, lowres, bad anatomy, worst quality, low quality",
"model_id": "sd1.5",
"controlnets": ["canny"],
"init_images": ["https://cdn.pariscityvision.com/library/image/5449.jpg"],
"controlnet_weights": [0.5],
"starting_control_steps": [],
"ending_control_steps": [],
"num_inference_steps": 20,
"samples": 1,
"guidance_scale": 7.5,
"height": 512,
"width": 512,
"safety_checker": false
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

Multicontrolnets

Input images

ImagePipeline-Multicontrolnet
{
"model_id": "0b397287-3449-4801-9a86-536465f6189f",
"controlnets": ["openpose", "canny"],
"prompt": "a giant standing in a fantasy landscape, best quality",
"negative_prompt": "monochrome, lowres, bad anatomy, worst quality, low quality",
"init_images": ["https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/person.png", "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/landscape.png"],
"num_inference_steps": 20,
"refiner": false,
"samples": 1,
"controlnet_weights": [1.0, 0.8],
"starting_control_steps": [0.0, 0.25],
"ending_control_steps": [1.0, 0.75],
"scheduler": "UniPCMultistepScheduler",
"guidance_scale": 7.5,
"width": 512,
"height": 512
}

Output Image

ImagePipeline-Multicontrolnet

JSON Parameters

ParameterPermissible valuesNotes
model_idstrmodel_id can be found in models page. Filter by SD-1.5 models
promptstr, 75 tokensCheck our Prompt Guide for tips. Please add embeddings prompts to your prompt
negative_promptstr, 75 tokensCheck our Prompt Guide for tips. Please add embeddings prompts to your prompt
num_inference_stepsint, [1-100]Noise is removed with each step, resulting in a higher-quality image over time. Ideal value 20-30
strengthfloat, [0-1]Optional denoise strength
samplesint, [1-4]Generates a maximum of 4 samples per API call
guidance_scalefloat, [1-20]Higher guidance scale prioritizes text prompt relevance but sacrifices image quality. Ideal value 7.5-12.5
widthintWidth in pixels. Lower than or equal to 512 for best results
heightintHeight in pixels. Lower than or equal to 512 for best results
seedintControlling the seed can help you generate reproducible images
controlnetstr, arrayPass the controlnet model names/ids. Default values: hed, canny, lineart, mlsd, scribble, shuffle, midas, seg, depth, openpose, normal , inpainting, normal.
controlnet_weightsfloat, arrayAdd weights for your controlnets
starting_control_stepsfloat, arrayAdd start value for your controlnets
ending_control_stepsfloat, arrayAdd stop value for your controlnets
lora_modelsstr, arrayPass the model_id(s) of LoRA models that can be found in models page
lora_weightsfloat, arrayStrength of the LoRA effect
embeddingsstr, arrayPass the model_id of embeddings models that can be found in models page
safety_checkerbooleanChecks for NSFW images and filters explicit images

Status

Your response will include a status.

  • If the status = SUCCESS, you will also have download_urls that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 4.
  • If the status = PENDING, you will receive a id. You can use the status endpoint to fetch your image using the id.
  • If the status = FAILURE, you will receive only an error message.

Use this endpoint to fetch the status:

  • https://api.imagepipeline.io/sd/controlnet/v1/status/{{id}}

Pass the API-Key as the authorization in the header.

](ControlNets-SD1.5.md)