Img2Img
In order to deploy the model you can use the identifier below:
- Stable Diffusion img2img:
sd-img-2-img
Pass a text prompt and an initial image to condition the generation of new images. Once you’ve deployed a model, you can follow this example of how to call the deployed endpoint:
Request Parameters
curl --location --request POST 'https://run.cerebrium.ai/sd-img-2-img-webhook/predict' \
--header 'Authorization: <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"prompt": "a photo of an astronaut riding a horse on mars.",
"image": "<BASE_64_STRING>"
"num_inference_steps": 50,
"guidance_scale": 7.5,
"num_images_per_prompt": 1,
"negative_prompt": "",
"seed": 120,
"file_url": "https://your-url.com/image.png"
"webhook_endpoint": "https://your-url.com"
}'
This is the Cerebrium API key used to authenticate your request. You can get it from your Cerebrium dashboard.
The prompt you would like your model to generate.
This is a base64 encoded string of your initial image.
The number of steps you would like the model to take to generate the image. In general, the results are better the more steps you use, however the more steps, the longer the generation takes. It defaults to 50 steps and is an optional parameter.
A way to increase the adherence to the conditional signal that guides the generation (text, in this case) as well as overall sample quality. In simple terms it forces the generation to better match the prompt potentially at the cost of image quality or diversity. This defaults to 7.5 and is an optional parameter.
The number of image variations you would like the model to generate. This is an optional parameter which defaults to 1.
The negative prompt is a parameter that tells Stable Diffusion what you don’t want to see in the generated images. This is an optional parameter that has an empty default value.
Make sure that generations are the exact same for the same prompts and images.
The url of a publicly accessible file where we can fetch your image from. Better to use for large files than base64 encoding.
The url endpoint you would like us to send the image results to once it has finished generating.
{
"run_id": "<UUID_STRING>",
"message": "Successfully generated image",
"result": [<BASE_64_STRING>]
}
Response Parameters
A unique identifier for the run that you can use to associate prompts with webhook endpoints.
Whether of not the response was successful
An array of base64 encoded strings of the image that you can convert into an image
curl --location --request POST 'https://run.cerebrium.ai/sd-img-2-img-webhook/predict' \
--header 'Authorization: <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"prompt": "a photo of an astronaut riding a horse on mars.",
"image": "<BASE_64_STRING>"
"num_inference_steps": 50,
"guidance_scale": 7.5,
"num_images_per_prompt": 1,
"negative_prompt": "",
"seed": 120,
"file_url": "https://your-url.com/image.png"
"webhook_endpoint": "https://your-url.com"
}'
{
"run_id": "<UUID_STRING>",
"message": "Successfully generated image",
"result": [<BASE_64_STRING>]
}