Stable Diffusion
On this page, we’ll dive into the stable diffusion tasks that are available in the PeerAI API.
Headers
- Name
x-api-group(optional)- Type
- string, default 'main'
- Description
The id of the peer-ai compute group you want to run this compute on.
- Name
x-api-key- Type
- string
- Description
The API key for your PeerAI account.
Stable Diffusion
Stable Diffusion is a generative model that can generate high-resolution images based on a given prompt and additional parameters.
- For Stable Diffusion 1.4, use
CompVis/stable-diffusion-v1-4with
model_options = {
revision: 'onnx',
quantized: false
}
- For Stable Diffusion 1.5, use
runwayml/stable-diffusion-v1-5with
model_options = {
revision: 'onnx',
quantized: false
}
- For Stable Diffusion 2.1, use
aislamov/stable-diffusion-2-1-base-onnxwith
model_options = {
revision: 'main',
quantized: false,
timestepType: 'float32'
}
Body
- Name
task- Type
- string
- Description
The task of the pipeline. e.g., 'sentiment-analysis', 'text-classification'
- Name
model(optional)- Type
- string, default null
- Description
The name of the pre-trained model to use. If not specified, the default model for the task will be used.
- Name
model_options(optional)- Type
- object, default null
- Description
An object containing the following properties:
revision(string): The revision of the model to use. e.g., 'main', 'onnx', 'quantized'quantized(boolean): Whether to use the quantized version of the model.timestepType(string): The timestep type of the model. e.g., 'float32', 'int64'
- Name
inputs.0- Type
- object
- Description
An object containing the following properties:
prompt(string): The text prompt to generate the image.strength(number): The strength of the prompt influence on the generated image. Should be between 0 and 1.n_steps(number): The number of steps to run the diffusion process.n_samples(number): The number of samples to generate.
Request
curl -X POST https://api.peer-ai.com/v1/pipeline \
-H "X-API-Group: {YOUR_COMPUTE_GROUP}" \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"task\": \"stable-diffusion\", \"model\": \"runwayml/stable-diffusion-v1-5\", \"model_options\": {\"revision\": \"onnx\", \"quantized\": false }, \"inputs\": {\"prompt\": \"Face of a yellow cat, high resolution, sitting on a park bench.\", \"strength\": 0.6, \"n_steps\": 10, \"n_samples\": 1 }}"
Response
[
{
"url": "blob:https://compute.peer-ai.com/55a46563-4372-4a97-9832-ac6bdff1b09f"
}
]
Stable Diffusion Image to Image
Stable Diffusion Image to Image is a generative model that can generate high-resolution images based on a given prompt, image and additional parameters.
Body
- Name
task- Type
- string
- Description
The task of the pipeline. e.g., 'sentiment-analysis', 'text-classification'
- Name
model(optional)- Type
- string, default null
- Description
The name of the pre-trained model to use. If not specified, the default model for the task will be used.
- Name
model_options(optional)- Type
- object, default null
- Description
An object containing the following properties:
revision(string): The revision of the model to use. e.g., 'main', 'onnx', 'quantized'quantized(boolean): Whether to use the quantized version of the model.timestepType(string): The timestep type of the model. e.g., 'float32', 'int64'
- Name
inputs.0- Type
- object
- Description
An object containing the following properties:
prompt(string): The text prompt to generate the image.strength(number): The strength of the prompt influence on the generated image. Should be between 0 and 1.n_steps(number): The number of steps to run the diffusion process.n_samples(number): The number of samples to generate.image(string): The URL of an image to use as a conditioning input.
Request
curl -X POST https://api.peer-ai.com/v1/pipeline \
-H "X-API-Group: {YOUR_COMPUTE_GROUP}" \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"task\": \"stable-diffusion\", \"model\": \"runwayml/stable-diffusion-v1-5\", \"model_options\": {\"revision\": \"onnx\", \"quantized\": false }, \"inputs\": {\"prompt\": \"Face of a yellow cat, high resolution, sitting on a park bench.\", \"strength\": 0.6, \"n_steps\": 10, \"n_samples\": 1, \"image\": \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png\"}}"
Response
[
{
"url": "blob:https://compute.peer-ai.com/55a46563-4372-4a97-9832-ac6bdff1b09f"
}
]
Stable Diffusion Inpainting
Stable Diffusion is a technique used for image inpainting, which involves filling in missing or corrupted parts of an image. It uses a generative model to generate plausible content for the missing regions based on the surrounding context.
Body
- Name
task- Type
- string
- Description
The task of the pipeline. e.g., 'stable-diffusion'
- Name
model(optional)- Type
- string, default null
- Description
The name of the pre-trained model to use. If not specified, the default model for the task will be used.
- Name
model_options(optional)- Type
- object, default null
- Description
An object containing the following properties:
revision(string): The revision of the model to use. e.g., 'main', 'onnx', 'quantized'quantized(boolean): Whether to use the quantized version of the model.timestepType(string): The timestep type of the model. e.g., 'float32', 'int64'
- Name
inputs.0- Type
- object
- Description
An object containing the following properties:
prompt(string): The text prompt to generate the image.strength(number): The strength of the prompt influence on the generated image. Should be between 0 and 1.n_steps(number): The number of steps to run the diffusion process.n_samples(number): The number of samples to generate.image(string): The URL of the image to inpaint.mask_image(string): The URL of the mask image indicating the areas to inpaint.
Request
curl -X POST https://api.peer-ai.com/v1/pipeline \
-H "X-API-Group: {YOUR_COMPUTE_GROUP}" \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"task\": \"stable-diffusion\", \"model_options\": {\"revision\": \"onnx\", \"quantized\": false }, \"inputs\": [{\"prompt\": \"Face of a yellow cat, high resolution, sitting on a park bench.\", \"strength\": 1.0, \"n_steps\": 5, \"n_samples\": 1, \"image\": \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png\", \"mask_image\": \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png\"}]}"
Response
[
{
"url": "blob:https://compute.peer-ai.com/55a46563-4372-4a97-9832-ac6bdff1b09f"
}
]
Stable Diffusion 1.5 Inpainting
Stable Diffusion 1.5 Inpainting is a technique used for image inpainting, which involves filling in missing or corrupted parts of an image. It uses a generative model to generate plausible content for the missing regions based on the surrounding context. This pipeline uses the specific Stable Diffusion 1.5 inpainting model.
Body
- Name
task- Type
- string
- Description
The task of the pipeline. e.g., 'sentiment-analysis', 'text-classification'
- Name
model(optional)- Type
- string, default null
- Description
The name of the pre-trained model to use. If not specified, the default model for the task will be used.
- Name
model_options(optional)- Type
- object, default null
- Description
An object containing the following properties:
revision(string): The revision of the model to use. e.g., 'main', 'onnx', 'quantized'quantized(boolean): Whether to use the quantized version of the model.timestepType(string): The timestep type of the model. e.g., 'float32', 'int64'
- Name
inputs.0- Type
- object
- Description
An object containing the following properties:
prompt(string): The text prompt to generate the image.n_steps(number): The number of steps to run the diffusion process.n_samples(number): The number of samples to generate.image(string): The URL of the image to inpaint.mask_image(string): The URL of the mask image indicating the areas to inpaint.
Request
curl -X POST https://api.peer-ai.com/v1/pipeline \
-H "X-API-Group: {YOUR_COMPUTE_GROUP}" \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"task\": \"stable-diffusion-inpaint\", \"model\": \"runwayml/stable-diffusion-inpainting\", \"model_options\": {\"revision\": \"onnx\", \"quantized\": false }, \"inputs\": [{\"prompt\": \"Face of a yellow cat, high resolution, sitting on a park bench.\", \"n_steps\": 10, \"n_samples\": 1, \"image\": \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png\", \"mask_image\": \"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png\"}]}"
Response
[
{
"url": "blob:https://compute.peer-ai.com/55a46563-4372-4a97-9832-ac6bdff1b09f"
}
]