Skip to content
sisbell edited this page May 8, 2023 · 1 revision

Prompt File

First, create a prompt file for images. Call it image.prompt.

Generate a picture of a ${creature} with ${feature}

The ${} is a value that can be substituted with a property. You don't have to use these in the prompt but they can be convenient if you want to vary the prompt without needing to create a separate file each time.

Project File

Now create a project file project.yaml.

---
projectName: image-generation
projectVersion: '2.3'
apiKeyFile: "../../api_key"
blocks:
  - blockId: image-1
    pluginName: ImageGptPlugin
    executions:
      #First Image
      - id: img-unicorn
        sizes:
          - 256
        prompt: image.prompt
        properties:
          creature: Unicorn
          feature: a gold horn and wings

      # Second Image
      - id: img-fish
        sizes:
          - 256
          - 512
        imageCount: 2
        responseFormat: b64_json
        prompt: image.prompt
        properties:
          creature: fish
          feature: giant eyes

Note: the total images generated is:

sizes.length * imageCount

For instance, for img-fish we have a sizes array of 2 items and an imageCount of 2.

2 * 2 = 4

The would produce 2 images of size 256 and two images of size 512.

The calculated prompts in the above example are:

Generate a picture of a Unicorn with a gold horn and wings

and

Generate a picture of a fish with giant eyes

Configuration

The project file above uses the ImageGptPlugin. The configuration is:

Field Description
sizes sizes of images to create: 256, 512, and 1024
imageCount number of images to generate. Optional, default value is 1.
responseFormat url or b64_json. Optional, default value is 'url'. Url points to a remote location for the images, while b64_json is embedded in the output field
prompt prompt file to use for generating the image
properties properties to substitute into the prompt

Output

If b64_json is specified as the responseFormat, the b64 blob will be included in the response, otherwise it includes a URL to the generated image.

Since img-fish has two sizes specified, two images for it are included in the output file. The output will be giving in the following format.

{
  "projectName": "image-generation",
  "projectVersion": "2,3",
  "blockId": "image-1",
  "blockRuns": [
    {
      "blockRun": 1,
      "blockResults": [
        {
          "prompt": "Generate a picture of a Unicorn with a gold horn and wings",
          "size": "256x256",
          "images": [
            {
              "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/..."
            }
          ]
        },
        {
          "prompt": "Generate a picture of a fish with giant eyes",
          "size": "256x256",
          "images": [
            {
              "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/..."
            }
          ]
        },
        {
          "prompt": "Generate a picture of a fish with giant eyes",
          "size": "512x512",
          "images": [
            {
              "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/..."
            }
          ]
        }
      ]
    }
  ]
}

The URL formate images will be downloaded. For b64, the file will be converted to png format. All images are saved in the following directory.

${output}/${projectName}/${projectVersion}/${blockId}/images

image image image

Clone this wiki locally