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
TThe 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:
- Text Encoder: Understands and expands prompts
- Diffusion Model: Generates images through iterative denoising
- Safety Systems: Filters inappropriate content
- Quality Enhancement: Upscaling and refinement
Properties
MaxPromptLength
Gets the maximum prompt length in characters.
int MaxPromptLength { get; }
Property Value
SupportedSizes
Gets the supported image sizes.
IReadOnlyList<DallE3ImageSize> SupportedSizes { get; }
Property Value
SupportsEditing
Gets whether the model supports image editing (inpainting).
bool SupportsEditing { get; }
Property Value
SupportsVariations
Gets whether the model supports image variations.
bool SupportsVariations { get; }
Property Value
Methods
CheckPromptSafety(string)
Checks if a prompt is likely to be rejected for safety reasons.
(bool IsSafe, IEnumerable<string> FlaggedCategories) CheckPromptSafety(string prompt)
Parameters
promptstringPrompt 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
imageTensor<T>Source image to create variations of.
countintNumber of variations to generate.
variationStrengthdoubleHow different from original (0-1).
sizeDallE3ImageSizeOutput 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
imageTensor<T>Original image to edit.
maskTensor<T>Mask indicating areas to edit (white = edit, black = keep).
promptstringDescription of what to generate in masked areas.
sizeDallE3ImageSizeOutput 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
promptstringPrompt 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
simplePromptstringBrief description.
styleDallE3StyleDesired 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
promptstringText description of the desired image.
sizeDallE3ImageSizeOutput image size.
qualityDallE3QualityQuality setting.
styleDallE3StyleStyle setting.
seedint?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
basePromptstringBase description of the subject.
variationsIEnumerable<string>List of variation descriptions (poses, angles, etc.).
consistencySeedintSeed for maintaining consistency.
sizeDallE3ImageSizeOutput 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
promptstringImage description.
useCasestringUse case: "social_media", "product_photo", "illustration", "concept_art", "stock_photo".
sizeDallE3ImageSizeOutput 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
promptstringText description of the desired images.
countintNumber of images to generate (1-4).
sizeDallE3ImageSizeOutput image size.
qualityDallE3QualityQuality setting.
styleDallE3StyleStyle 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
promptstringPattern or texture description.
sizeDallE3ImageSizeOutput 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
promptstringOverall description.
compositionGuideIEnumerable<(string Element, string Position, double Prominence)>Composition elements with positions.
sizeDallE3ImageSizeOutput 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
promptstringOriginal text prompt.
sizeDallE3ImageSizeOutput image size.
qualityDallE3QualityQuality setting.
styleDallE3StyleStyle 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
promptstringContent description.
artisticStylestringStyle: "photorealistic", "oil_painting", "watercolor", "digital_art", "anime", "sketch", "3d_render".
sizeDallE3ImageSizeOutput image size.
qualityDallE3QualityQuality 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
promptstringOverall image description.
textToRenderstringExact text to appear in the image.
textPlacementstringWhere to place text: "top", "center", "bottom", "overlay".
sizeDallE3ImageSizeOutput 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
imageTensor<T>Original image.
directionstringDirection to extend: "left", "right", "top", "bottom", "all".
extensionPixelsintHow many pixels to extend.
promptstringOptional 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
imageTensor<T>Image to upscale.
scaleFactorintUpscale factor (2 or 4).
enhanceDetailsboolWhether to enhance details during upscaling.
Returns
- Tensor<T>
Upscaled image.