Stable Diffusion Training

In this guide, we will look at how to train a model using Diffute and the Stable Diffusion models which it supports.

Basic requirements

Training requires 4 things: an API key, an organization_id, a project_id within that organization and a minimum of 7 training images. (Some may assert that's actually 10 things required in total.)

Sending training requests

Example request to train a model

  curl --request PUT \
  --url https://api.diffute.com/v1/project/<organization_id>/<project_id>/media/train \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: long-api-key/default' \
  --data '{
	"class_prompt" : "a photo of pocketbook",
	"training_resolution" : 512,
	"learning_rate" : "1e-6",
	"max_train_steps" : 600,
	"num_class_images" : 84,
	"pretrained_model_name" : "runwayml/stable-diffusion-v1-5",
}'

In the example above, multiple prompts were sent in a single request. Each individial prompt in prompts has a unique key called name while the overall request also has a name key used to identify the entire request. It may be convenient to use a customer id or some other identifier.

Using this approach allows you to receive payloads with unique identifiers that your application expects.

Inference

  • Name
    name
    Type
    Description

    A string representing the name of the overall request.

  • Name
    pretrained_model_name
    Type
    Description

    An optional string representing a pretrained model name.

  • Name
    prompts
    Type
    Description

    A list of prompts.

  • Name
    webhook
    Type
    Description

    An optional URL (strictly HTTPS) representing the webhook.

  • Name
    secret
    Type
    Description

    An optional string representing a secret.

Inference payload

{
  "name" : "Houston",
  "pretrained_model_name" : "stabilityai/stable-diffusion-xl-base-1.0",
  "prompts": [
  {
    "name": "Ansel_Adams",
    "prompt": "A black and white photograph capturing the beauty and grandeur of Yosemite National Park",
    "num_images": 3,
    "height": 1024,
    "width": 768,
    "style": "photography in the style of Ansel Adams"
  },
  {
    "name": "Henri_Rousseau",
    "prompt": "A painting of a lush jungle scene with a variety of exotic plants and animals",
    "num_images": 3,
    "height": 1024,
    "width": 768,
    "style": "painting in the style of Henri Rousseau"
  },
  {
    "name": "Rachel_Ruysch",
    "prompt": "Still life painting featuring a variety of flowers and plants found in a garden",
    "num_images": 3,
    "height": 1024,
    "width": 768,
    "style": "painting in the style of Rachel Ruysch"
  }
  ],
  "webhook" : "https://example.com/customer/12345",
  "secret" : "4f986e48-0129-480e-996a-728ea57c020c"
}