SD15DepthControlNetModel
Depth-conditioned ControlNet pipeline built on Stable Diffusion 1.5.
Takes an input image and a text prompt. A depth map is estimated from the
image using Intel's DPT-Hybrid-MiDaS model, then fed as a spatial
conditioning signal into the lllyasviel/sd-controlnet-depth ControlNet
backbone together with the runwayml/stable-diffusion-v1-5 diffusion
pipeline. The result is a 512 x 512 image that respects both the text
description and the 3-D structure of the original scene.
References
- [1] Zhang & Agrawala, "Adding Conditional Control to Text-to-Image Diffusion Models", ICCV 2023. https://arxiv.org/abs/2302.05543
- [2] https://huggingface.co/lllyasviel/sd-controlnet-depth
Parameters
- num_inference_steps : integer, default=
20 - Number of denoising steps to run. More steps refine the image but increase generation time. Typical range: 20-30 for fast results, 40-50 for higher quality.
- controlnet_conditioning_scale : number, default=
1.0 - Weight of the ControlNet depth conditioning relative to the base diffusion pipeline (range 0.0-2.0). At 0.0 the depth map has no effect; at 1.0 the output closely follows the input structure; above 1.5 depth dominates and may produce rigid results.
- guidance_scale : number, default=
7.5 - Classifier-Free Guidance (CFG) scale. Controls how strictly the image follows the text prompt. Values 7-9 are typical for SD 1.5.
- device : string, default=
CPU - Hardware device for inference. GPU is strongly recommended for diffusion models. CPU inference is possible but very slow.
- gpu_memory_mode : string, default=
auto - How much of the model is kept on the GPU. 'auto' measures free VRAM when the model loads and picks the fastest option that fits. 'full' keeps everything on the GPU (fastest, most VRAM). 'model' moves one component (text encoder, denoiser, VAE) to the GPU at a time. 'sequential' streams the weights layer by layer: slowest, but runs large models on small GPUs. Ignored on CPU.
Methods
generate(self, input: Tuple[ForwardRef('Image.Image'), str]) -> List[Any]
SD15DepthControlNetModelGenerate output from a generative model.
Parameters
- input : Tuple[Image.Image, str]
- Input image and text prompt.
Returns
- List[Any]
- Generated output images in a list.
component_dir(cls) -> pathlib.Path
DownloadableMixinReturn this component's own storage directory.
Returns
- pathlib.Path
<COMPONENT_PATH>/<ClassName>.
delete(cls) -> None
DownloadableMixinRemove the component's downloaded artifacts.
download(cls, report: Optional[Callable[[Optional[float], Optional[str]], NoneType]] = None) -> None
HFDownloadableMixinDownload all repos listed in hf_repos() into component_dir().
Parameters
- report : ProgressReporter, optional
- Callback invoked before each repo download with
report(None, "Downloading <repo_id>").Nonemeans no progress reporting.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_metadata(cls) -> Dict[str, Any]
BaseGenerativeModelGet metadata values for the current generative model.
Returns
- Dict[str, Any]
- Dictionary indicating whether the model requires a download before use and the expected download size in bytes.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
hf_repos(cls) -> List[Union[Tuple[str, str], Tuple[str, str, List[str]]]]
HFDownloadableMixinReturn the repo entries this component needs.
Returns
- list of tuple
- Each entry is either
(repo_id, repo_type)or(repo_id, repo_type, allow_patterns).
is_downloaded(cls) -> bool
HFDownloadableMixinReturn whether all repo directories exist and are non-empty.
Returns
- bool
Truewhen every repo listed inhf_repos()has a non-empty local directory;Falseotherwise (including when the list is empty).
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.