Model configuration

Model configuration is currently available for text-to-image based models and will be extended to other types of models, such as text-to-text and image-to-image, in the future.

Image IO

Image IO is available from 2.1.0

Magnolia AI Accelerator Image IO enables a flexible way for developers to add image models such as DallE·2/3 and Flux for AI powered image generation.

Installing with Maven

<dependency>
  <groupId>info.magnolia.ai</groupId>
  <artifactId>magnolia-ai-accelerator-image-io</artifactId>
  <version>2.1.0</version>
</dependency>

Dall-E image models

<dependency>
  <groupId>info.magnolia.ai</groupId>
  <artifactId>magnolia-ai-accelerator-openai</artifactId>
  <version>2.1.0</version>
</dependency>

Flux image models

<dependency>
  <groupId>info.magnolia.ai</groupId>
  <artifactId>magnolia-ai-accelerator-fal-ai</artifactId>
  <version>2.1.0</version>
</dependency>

Configuration

Image models can be added to your light module by creating a aiTextToImageModels folder and adding a <your-image-to-image-model>.yaml file with the following configuration:

modelName: <your-image-to-image-model>
id: <your-image-to-image-model>
appId: <your-image-to-image-model>
scriptLocation: <image-to-image-model-script>(2)
modelParameters:
  <model-parameter-name>:
    type: <PARAMETER-TYPE>(1)
    required: <true/false>
    description: <DESCRIPTION>
    defaultValue: <DEFAULT-VALUE>
1 Parameters present in this configuration will have a UI representation and should represent the configurable parameters of the image model. Available parameter types are:
  • STRING

  • PROMPT, // Special STRING type to render a prompt field

  • NUMBER

  • ENUM

2 The executor script is a script that will be executed by the AI accelerator to and should include API calls against the image model API. The script is required to have a default export class that has the method generateImage(appState, parameters).

Example:

export default class {
  /**
    *
    * @param appState contains Application State (provided by AI Accelerator)
    * @param parameters contains all configured model parameters i.e (2)
    * @returns {{b64_json: String, width: Number, height: Number, prompt: String}[]}>
    */
  async generateImage(appState, parameters) {
    const images = callImageModelApi(parameters);
    return images;
  }
}

Sample Image to Image models

OpenAI Dall-E·2

Sample model configuration for generating images with Dall-E·2 (https://platform.openai.com/docs/api-reference/images).

modelName: Dall-E·2
id: dall-e-2
appId: dall-e-2
modelParameters:
  prompt:
    type: PROMPT
    required: true
    description: The prompt to generate an image from.
  n:
    type: NUMBER
    description: |
      The number of images to generate. Must be between 1 and 10.
    defaultValue: 1
  size:
    type: ENUM
    description: |
      The size of the generated images. Defaults to 1024x1024
      Must be one of 1024x1024, 1792x1024, or 1024x1792
    enumValues: [1024x1024, 1792x1024, 1024x1792]
    defaultValue: 1024x1024

scriptLocation: /ai-accelerator-openai/webresources/DallEImageModelHandler.js

OpenAI Dall-E·3

Sample model configuration for generating images with Dall-E·3 (https://platform.openai.com/docs/api-reference/images).

modelName: OpenAI Dall-E·3
id: dall-e-3
appId: dall-e-3
modelParameters:
  prompt:
    type: PROMPT
    required: true
    description: The prompt to generate an image from.
  size:
    type: ENUM
    description: |
      The size of the generated images. Defaults to 1024x1024
      Must be one of 1024x1024, 1792x1024, or 1024x1792
    enumValues: [1024x1024, 1792x1024, 1024x1792]
    defaultValue: 1024x1024
  style:
    type: ENUM
    description: |
      The style of the generated images. Must be one of vivid or natural. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.
    enumValues: [vivid, natural]
    defaultValue: vivid
  quality:
    type: ENUM
    description: |
      The quality of the image that will be generated. hd creates images with finer details and greater consistency across the image
    enumValues: [standard, hd]
    defaultValue: standard

scriptLocation: /ai-accelerator-openai/webresources/DallEImageModelHandler.js

FLUX.1.0 [dev]

Sample configuration for FLUX.1.0 [dev] model (https://fal.ai/models/fal-ai/flux/dev).

modelName: FLUX.1 [dev]
id: flux/dev
appId: flux
modelParameters:
  prompt:
    type: PROMPT
    required: true
    description: The prompt to generate an image from.
  image_size:
    type: ENUM
    description: |
      The size of the generated image. Default value: landscape_4_3
      Possible enum values: square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9
    enumValues: [square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9]
    defaultValue: landscape_4_3
  num_outputs:
    type: NUMBER
    description: "The number of images to generate. Default value: 1"
    defaultValue: 1
  guidance_scale:
    type: NUMBER
    description: "The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you. Default value: 3.5"
    defaultValue: 3.5
  num_inference_steps:
    type: NUMBER
    description: "The number of inference steps to perform. Default value: 28"
    defaultValue: 28

scriptLocation: /ai-accelerator-fal-ai/webresources/FluxImageModelHandler.js

FLUX.1.1 [pro]

Sample model configuration for the FLUX.1.1 [pro] model (https://fal.ai/models/fal-ai/flux-pro/v1.1/api).

modelName: FLUX.1.1 [pro]
id: flux-pro/v1.1
appId: flux-pro
modelParameters:
  prompt:
    type: PROMPT
    required: true
    description: The prompt to generate an image from.
  image_size:
    type: ENUM
    description: |
      The size of the generated image. Default value: landscape_4_3
      Possible enum values: square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9
    enumValues: [square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9]
    defaultValue: landscape_4_3
  num_outputs:
    type: NUMBER
    description: "The number of images to generate. Default value: 1"
    defaultValue: 1
  guidance_scale:
    type: NUMBER
    description: "The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you. Default value: 3.5"
    defaultValue: 3.5
  num_inference_steps:
    type: NUMBER
    description: "The number of inference steps to perform. Default value: 28"
    defaultValue: 28

scriptLocation: /ai-accelerator-fal-ai/webresources/FluxImageModelHandler.js
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the AI Accelerator module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules