sketchkit.colorization.controlnet_scribble package

Module contents

ControlNet Scribble Model for Sketch Colorization (SDXL Version)

class sketchkit.colorization.controlnet_scribble.ControlNetScribbleModel(device: str = 'cuda', controlnet_model: str = 'xinsir/controlnet-scribble-sdxl-1.0', sd_model: str = 'stabilityai/stable-diffusion-xl-base-1.0', vae_model: str = 'madebyollin/sdxl-vae-fp16-fix', torch_dtype: dtype = torch.float16, safety_checker: bool = False, **kwargs: Any)[source]

Bases: object

ControlNet model with scribble conditioning for sketch colorization using SDXL.

pipeline

The loaded diffusers pipeline.

Type:

StableDiffusionXLControlNetPipeline

device

Computation device.

Type:

str

generate(control_image: Image, prompt: str, size: int | Tuple[int, int] | None = None, negative_prompt: str = '', num_inference_steps: int = 30, guidance_scale: float = 7.5, controlnet_conditioning_scale: float = 1.0, seed: int | None = None, **kwargs: Any) Image[source]

Generates an image from a scribble sketch using SDXL ControlNet.

Parameters:
  • control_image (Image.Image) – The input conditioning scribble image.

  • prompt (str) – Text prompt describing the desired output.

  • size (Optional[Union[int, Tuple[int, int]]]) – Target resolution. If None, it auto-scales proportionally based on a 1024x1024 baseline.

  • negative_prompt (str) – Text prompt detailing what to avoid.

  • num_inference_steps (int) – Number of denoising steps. Defaults to 30.

  • guidance_scale (float) – CFG scale for text guidance. Defaults to 7.5.

  • controlnet_conditioning_scale (float) – Strength of the ControlNet. Defaults to 1.0.

  • seed (Optional[int]) – Random seed for deterministic generation.

  • **kwargs (Any) – Additional arguments for the pipeline.

Returns:

The generated image.

Return type:

Image.Image

Raises:

RuntimeError – If image generation fails during pipeline execution.