Skip to main content

ControlNetTask

GenerativeTask
DashAI.back.tasks.ControlNetTask

Task for structure-conditioned image generation using ControlNet pipelines.

ControlNet tasks accept a source image and a text prompt as inputs and produce one or more generated images. The source image is pre-processed by the model (e.g. depth estimation, HED soft-edge detection, OpenPose skeleton extraction, or Canny edge detection) to derive a spatial conditioning signal, which guides the diffusion process alongside the text prompt.

Methods

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

Defined on ControlNetTask

Change the inputs to suit the image generation task.

Parameters

input : List[ProcessData]
Input data to be prepared, a list of ProcessData objects

Returns

str
Input with the new types

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

Defined on ControlNetTask

Prepare the input for the database.

Parameters

input : List[Union[bytes, str]]
List containing the image bytes and the prompt string.

Returns

List[Tuple[str, str]]
Image path and prompt

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

Defined on ControlNetTask

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

Parameters

input : List[ProcessData]
Input data to be processed, a list of ProcessData objects

Returns

List[ProcessData]
Processed input data, a list of ProcessData objects

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

Defined on ControlNetTask

Process the output of a generative model.

Parameters

output : List[Any]
list of images to be processed
path : Optional[str], optional
Path to save the output, by default None

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 ControlNetTask

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

Parameters

output : List[ProcessData]
Output data to be processed, a list of ProcessData objects

Returns

List[ProcessData]
Processed output data, a list of ProcessData objects

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".