Skip to main content

TextToImageGenerationTask

GenerativeTask
DashAI.back.tasks.TextToImageGenerationTask

Task for generating images from natural-language text prompts.

Text-to-image generation uses a diffusion model conditioned on a text description to synthesise novel images. The task accepts a single string prompt as input and produces one or more PIL Image objects as output. The output images are saved as files and their paths are returned for the frontend to display.

Methods

prepare_for_task(self, input: List[DashAI.back.dependencies.database.models.ProcessData], **kwargs: Any) -> str

Defined on TextToImageGenerationTask

Change the inputs to suit the image generation task.

Parameters

inputs : str
Input to be changed

Returns

str
Input with the new types

prepare_input_for_database(self, input: List[str], **kwargs: Any) -> List[Tuple[str, str]]

Defined on TextToImageGenerationTask

Prepare the input for the database.

Parameters

input : str
Input to be changed

Returns

List[Tuple[str, str]]
Input with the new types as a list of tuples containing the data and its type

process_input_from_database(self, input: List[DashAI.back.dependencies.database.models.ProcessData], **kwargs: Any) -> List[DashAI.back.dependencies.database.models.ProcessData]

Defined on TextToImageGenerationTask

Process the input of an image generation model from the database.

Parameters

input : List[str]
List of prompts

Returns

List[str]
List of prompts

process_output(self, output: List[Any], **kwargs: Any) -> List[Tuple[str, str]]

Defined on TextToImageGenerationTask

Process the output of a generative model.

Parameters

output : List[Any]
list of images to be processed

Returns

List[Tuple[str, str]]
Processed output data as a list of tuples containing the data and its type

process_output_from_database(self, output: List[DashAI.back.dependencies.database.models.ProcessData], **kwargs: Any) -> List[DashAI.back.dependencies.database.models.ProcessData]

Defined on TextToImageGenerationTask

Process the output of an image generation model from the database.

Parameters

output : List[str]
List of paths to the images

Returns

List[str]
List of base64 encoded images

get_metadata(cls) -> Dict[str, Any]

Defined on BaseGenerativeTask

Return serialisable metadata for the current generative task.

Parameters

cls : type
The task class (injected automatically by Python for classmethods).

Returns

Dict[str, Any]
Dictionary with keys "inputs_types", "outputs_types", "inputs_cardinality", and "outputs_cardinality".