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]
ControlNetTaskChange 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]]
ControlNetTaskPrepare 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]
ControlNetTaskProcess 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]]
ControlNetTaskProcess 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]
ControlNetTaskProcess 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]
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".