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
TextToImageGenerationTaskChange 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]]
TextToImageGenerationTaskPrepare 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]
TextToImageGenerationTaskProcess 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]]
TextToImageGenerationTaskProcess 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]
TextToImageGenerationTaskProcess 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]
BaseGenerativeTaskReturn 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".