Table of Contents

Interface IDallE3Model<T>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Defines the contract for DALL-E 3-style text-to-image generation models.

public interface IDallE3Model<T>

Type Parameters

T

The numeric type used for calculations.

Remarks

DALL-E 3 represents a significant advancement in text-to-image generation, with improved prompt following, text rendering, and overall image quality. It uses a combination of diffusion models and language understanding.

For Beginners: DALL-E 3 creates images from text descriptions!

Key capabilities:

  • High-fidelity image generation from text prompts
  • Accurate text rendering within images
  • Complex scene composition with multiple objects
  • Style control (vivid vs natural)
  • Multiple aspect ratios and sizes

Architecture concepts:

  1. Text Encoder: Understands and expands prompts
  2. Diffusion Model: Generates images through iterative denoising
  3. Safety Systems: Filters inappropriate content
  4. Quality Enhancement: Upscaling and refinement

Properties

MaxPromptLength

Gets the maximum prompt length in characters.

int MaxPromptLength { get; }

Property Value

int

SupportedSizes

Gets the supported image sizes.

IReadOnlyList<DallE3ImageSize> SupportedSizes { get; }

Property Value

IReadOnlyList<DallE3ImageSize>

SupportsEditing

Gets whether the model supports image editing (inpainting).

bool SupportsEditing { get; }

Property Value

bool

SupportsVariations

Gets whether the model supports image variations.

bool SupportsVariations { get; }

Property Value

bool

Methods

CheckPromptSafety(string)

Checks if a prompt is likely to be rejected for safety reasons.

(bool IsSafe, IEnumerable<string> FlaggedCategories) CheckPromptSafety(string prompt)

Parameters

prompt string

Prompt to check.

Returns

(bool IsSafe, IEnumerable<string> FlaggedCategories)

Whether the prompt is safe and any flagged categories.

CreateVariations(Tensor<T>, int, double, DallE3ImageSize)

Generates variations of an existing image.

IEnumerable<Tensor<T>> CreateVariations(Tensor<T> image, int count = 4, double variationStrength = 0.5, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

image Tensor<T>

Source image to create variations of.

count int

Number of variations to generate.

variationStrength double

How different from original (0-1).

size DallE3ImageSize

Output image size.

Returns

IEnumerable<Tensor<T>>

Collection of image variations.

Edit(Tensor<T>, Tensor<T>, string, DallE3ImageSize)

Edits an existing image based on a prompt and mask.

Tensor<T> Edit(Tensor<T> image, Tensor<T> mask, string prompt, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

image Tensor<T>

Original image to edit.

mask Tensor<T>

Mask indicating areas to edit (white = edit, black = keep).

prompt string

Description of what to generate in masked areas.

size DallE3ImageSize

Output image size.

Returns

Tensor<T>

Edited image.

Remarks

For Beginners: Change specific parts of an image!

The mask tells the model where to make changes:

  • White (255) areas will be regenerated based on prompt
  • Black (0) areas will be preserved from the original
  • Gray areas blend between original and generated

EstimateQuality(string)

Estimates the generation quality before actually generating.

(T PredictedQuality, IEnumerable<string> Suggestions) EstimateQuality(string prompt)

Parameters

prompt string

Prompt to evaluate.

Returns

(T PredictedQuality, IEnumerable<string> Suggestions)

Predicted quality score and improvement suggestions.

ExpandPrompt(string, DallE3Style)

Expands a simple prompt into a more detailed description.

string ExpandPrompt(string simplePrompt, DallE3Style style = DallE3Style.Vivid)

Parameters

simplePrompt string

Brief description.

style DallE3Style

Desired style for expansion.

Returns

string

Expanded, detailed prompt.

Generate(string, DallE3ImageSize, DallE3Quality, DallE3Style, int?)

Generates an image from a text prompt.

Tensor<T> Generate(string prompt, DallE3ImageSize size = DallE3ImageSize.Square1024, DallE3Quality quality = DallE3Quality.Standard, DallE3Style style = DallE3Style.Vivid, int? seed = null)

Parameters

prompt string

Text description of the desired image.

size DallE3ImageSize

Output image size.

quality DallE3Quality

Quality setting.

style DallE3Style

Style setting.

seed int?

Optional seed for reproducibility.

Returns

Tensor<T>

Generated image tensor [channels, height, width].

Remarks

For Beginners: The main function - describe what you want!

Tips for good prompts:

  • Be specific about subject, style, and composition
  • Include lighting and mood descriptions
  • Mention artistic style if desired (e.g., "oil painting", "digital art")
  • Describe spatial relationships clearly

GenerateConsistentSet(string, IEnumerable<string>, int, DallE3ImageSize)

Generates a consistent set of images (same character/scene, different poses/angles).

IEnumerable<Tensor<T>> GenerateConsistentSet(string basePrompt, IEnumerable<string> variations, int consistencySeed, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

basePrompt string

Base description of the subject.

variations IEnumerable<string>

List of variation descriptions (poses, angles, etc.).

consistencySeed int

Seed for maintaining consistency.

size DallE3ImageSize

Output image size.

Returns

IEnumerable<Tensor<T>>

Collection of consistent images.

GenerateForUseCase(string, string, DallE3ImageSize)

Generates an image optimized for a specific use case.

Tensor<T> GenerateForUseCase(string prompt, string useCase, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

prompt string

Image description.

useCase string

Use case: "social_media", "product_photo", "illustration", "concept_art", "stock_photo".

size DallE3ImageSize

Output image size.

Returns

Tensor<T>

Generated image optimized for use case.

GenerateMultiple(string, int, DallE3ImageSize, DallE3Quality, DallE3Style)

Generates multiple images from a text prompt.

IEnumerable<Tensor<T>> GenerateMultiple(string prompt, int count = 4, DallE3ImageSize size = DallE3ImageSize.Square1024, DallE3Quality quality = DallE3Quality.Standard, DallE3Style style = DallE3Style.Vivid)

Parameters

prompt string

Text description of the desired images.

count int

Number of images to generate (1-4).

size DallE3ImageSize

Output image size.

quality DallE3Quality

Quality setting.

style DallE3Style

Style setting.

Returns

IEnumerable<Tensor<T>>

Collection of generated image tensors.

GenerateTileable(string, DallE3ImageSize)

Generates a seamlessly tileable image.

Tensor<T> GenerateTileable(string prompt, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

prompt string

Pattern or texture description.

size DallE3ImageSize

Output image size.

Returns

Tensor<T>

Tileable image.

Remarks

Useful for creating textures, wallpapers, and backgrounds that can be repeated without visible seams.

GenerateWithComposition(string, IEnumerable<(string Element, string Position, double Prominence)>, DallE3ImageSize)

Generates an image with controlled composition.

Tensor<T> GenerateWithComposition(string prompt, IEnumerable<(string Element, string Position, double Prominence)> compositionGuide, DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

prompt string

Overall description.

compositionGuide IEnumerable<(string Element, string Position, double Prominence)>

Composition elements with positions.

size DallE3ImageSize

Output image size.

Returns

Tensor<T>

Generated image following composition guide.

Remarks

For Beginners: Control where things appear in your image!

Composition guide format: [("subject", "center", 0.5), ("background", "back", 0.2), ("accent", "bottom-right", 0.3)]

GenerateWithPrompt(string, DallE3ImageSize, DallE3Quality, DallE3Style)

Generates an image with the revised/expanded prompt returned.

(Tensor<T> Image, string RevisedPrompt) GenerateWithPrompt(string prompt, DallE3ImageSize size = DallE3ImageSize.Square1024, DallE3Quality quality = DallE3Quality.Standard, DallE3Style style = DallE3Style.Vivid)

Parameters

prompt string

Original text prompt.

size DallE3ImageSize

Output image size.

quality DallE3Quality

Quality setting.

style DallE3Style

Style setting.

Returns

(Tensor<T> Image, string RevisedPrompt)

Generated image and the expanded prompt used.

Remarks

DALL-E 3 internally expands prompts for better results. This method returns both the image and the expanded prompt so you can see how your prompt was interpreted.

GenerateWithStyle(string, string, DallE3ImageSize, DallE3Quality)

Generates an image in a specific artistic style.

Tensor<T> GenerateWithStyle(string prompt, string artisticStyle, DallE3ImageSize size = DallE3ImageSize.Square1024, DallE3Quality quality = DallE3Quality.Standard)

Parameters

prompt string

Content description.

artisticStyle string

Style: "photorealistic", "oil_painting", "watercolor", "digital_art", "anime", "sketch", "3d_render".

size DallE3ImageSize

Output image size.

quality DallE3Quality

Quality setting.

Returns

Tensor<T>

Generated image in specified style.

GenerateWithText(string, string, string, DallE3ImageSize)

Generates an image with specific text rendered in it.

Tensor<T> GenerateWithText(string prompt, string textToRender, string textPlacement = "center", DallE3ImageSize size = DallE3ImageSize.Square1024)

Parameters

prompt string

Overall image description.

textToRender string

Exact text to appear in the image.

textPlacement string

Where to place text: "top", "center", "bottom", "overlay".

size DallE3ImageSize

Output image size.

Returns

Tensor<T>

Generated image with text.

Remarks

DALL-E 3 has improved text rendering capabilities compared to earlier models. Use this method when you need specific text to appear in the image.

Outpaint(Tensor<T>, string, int, string?)

Outpaints an image, extending it beyond its original boundaries.

Tensor<T> Outpaint(Tensor<T> image, string direction, int extensionPixels, string? prompt = null)

Parameters

image Tensor<T>

Original image.

direction string

Direction to extend: "left", "right", "top", "bottom", "all".

extensionPixels int

How many pixels to extend.

prompt string

Optional prompt to guide the extension.

Returns

Tensor<T>

Extended image.

Upscale(Tensor<T>, int, bool)

Upscales an image to higher resolution.

Tensor<T> Upscale(Tensor<T> image, int scaleFactor = 2, bool enhanceDetails = true)

Parameters

image Tensor<T>

Image to upscale.

scaleFactor int

Upscale factor (2 or 4).

enhanceDetails bool

Whether to enhance details during upscaling.

Returns

Tensor<T>

Upscaled image.