diffusers / controlnet-depth-sdxl-1.0-small

huggingface.co
Total runs: 1.7K
24-hour runs: -48
7-day runs: 97
30-day runs: -327
Model's Last Updated: August 16 2023
text-to-image

Introduction of controlnet-depth-sdxl-1.0-small

Model Details of controlnet-depth-sdxl-1.0-small

SDXL-controlnet: Depth

These are controlnet weights trained on stabilityai/stable-diffusion-xl-base-1.0 with depth conditioning. This checkpoint is 7x smaller than the original XL controlnet checkpoint. You can find some example images in the following.

prompt: donald trump, serious look, cigar in the mouth, 70mm, film still, head shot open

prompt: spiderman lecture, photorealistic images_0)

prompt: aerial view, a futuristic research complex in a bright foggy jungle, hard lighting images_1)

prompt: megatron in an apocalyptic world ground, runied city in the background, photorealistic images_2)

Usage

Make sure to first install the libraries:

pip install accelerate transformers safetensors diffusers

And then we're ready to go:

import torch
import numpy as np
from PIL import Image

from transformers import DPTFeatureExtractor, DPTForDepthEstimation
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
from diffusers.utils import load_image


depth_estimator = DPTForDepthEstimation.from_pretrained("Intel/dpt-hybrid-midas").to("cuda")
feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-hybrid-midas")
controlnet = ControlNetModel.from_pretrained(
    "diffusers/controlnet-depth-sdxl-1.0-small",
    variant="fp16",
    use_safetensors=True,
    torch_dtype=torch.float16,
).to("cuda")
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16).to("cuda")
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    controlnet=controlnet,
    vae=vae,
    variant="fp16",
    use_safetensors=True,
    torch_dtype=torch.float16,
).to("cuda")
pipe.enable_model_cpu_offload()

def get_depth_map(image):
    image = feature_extractor(images=image, return_tensors="pt").pixel_values.to("cuda")
    with torch.no_grad(), torch.autocast("cuda"):
        depth_map = depth_estimator(image).predicted_depth

    depth_map = torch.nn.functional.interpolate(
        depth_map.unsqueeze(1),
        size=(1024, 1024),
        mode="bicubic",
        align_corners=False,
    )
    depth_min = torch.amin(depth_map, dim=[1, 2, 3], keepdim=True)
    depth_max = torch.amax(depth_map, dim=[1, 2, 3], keepdim=True)
    depth_map = (depth_map - depth_min) / (depth_max - depth_min)
    image = torch.cat([depth_map] * 3, dim=1)

    image = image.permute(0, 2, 3, 1).cpu().numpy()[0]
    image = Image.fromarray((image * 255.0).clip(0, 255).astype(np.uint8))
    return image


prompt = "stormtrooper lecture, photorealistic"
image = load_image("https://huggingface.co/lllyasviel/sd-controlnet-depth/resolve/main/images/stormtrooper.png")
controlnet_conditioning_scale = 0.5  # recommended for good generalization

depth_image = get_depth_map(image)

images = pipe(
    prompt, image=depth_image, num_inference_steps=30, controlnet_conditioning_scale=controlnet_conditioning_scale,
).images
images[0]

images[0].save(f"stormtrooper_grid.png")

To more details, check out the official documentation of StableDiffusionXLControlNetPipeline .

🚨 Please note that this checkpoint is experimental and there's a lot of room for improvement. We encourage the community to build on top of it, improve it, and provide us with feedback. 🚨

Training

Our training script was built on top of the official training script that we provide here . You can refer to this script for full discolsure.

  • This checkpoint does not perform distillation. We just use a smaller ControlNet initialized from the SDXL UNet. We encourage the community to try and conduct distillation too. This resource might be of help in this regard .
  • To learn more about how the ControlNet was initialized, refer to this code block .
  • It does not have any attention blocks.
  • The model works pretty good on most conditioning images. But for more complex conditionings, the bigger checkpoints might be better. We are still working on improving the quality of this checkpoint and looking for feedback from the community.
  • We recommend playing around with the controlnet_conditioning_scale and guidance_scale arguments for potentially better image generation quality.
Training data

The model was trained on 3M images from LAION aesthetic 6 plus subset, with batch size of 256 for 50k steps with constant learning rate of 3e-5.

Compute

One 8xA100 machine

Mixed precision

FP16

Runs of diffusers controlnet-depth-sdxl-1.0-small on huggingface.co

1.7K
Total runs
-48
24-hour runs
-123
3-day runs
97
7-day runs
-327
30-day runs

More Information About controlnet-depth-sdxl-1.0-small huggingface.co Model

More controlnet-depth-sdxl-1.0-small license Visit here:

https://choosealicense.com/licenses/openrail++

controlnet-depth-sdxl-1.0-small huggingface.co

controlnet-depth-sdxl-1.0-small huggingface.co is an AI model on huggingface.co that provides controlnet-depth-sdxl-1.0-small's model effect (), which can be used instantly with this diffusers controlnet-depth-sdxl-1.0-small model. huggingface.co supports a free trial of the controlnet-depth-sdxl-1.0-small model, and also provides paid use of the controlnet-depth-sdxl-1.0-small. Support call controlnet-depth-sdxl-1.0-small model through api, including Node.js, Python, http.

controlnet-depth-sdxl-1.0-small huggingface.co Url

https://huggingface.co/diffusers/controlnet-depth-sdxl-1.0-small

diffusers controlnet-depth-sdxl-1.0-small online free

controlnet-depth-sdxl-1.0-small huggingface.co is an online trial and call api platform, which integrates controlnet-depth-sdxl-1.0-small's modeling effects, including api services, and provides a free online trial of controlnet-depth-sdxl-1.0-small, you can try controlnet-depth-sdxl-1.0-small online for free by clicking the link below.

diffusers controlnet-depth-sdxl-1.0-small online free url in huggingface.co:

https://huggingface.co/diffusers/controlnet-depth-sdxl-1.0-small

controlnet-depth-sdxl-1.0-small install

controlnet-depth-sdxl-1.0-small is an open source model from GitHub that offers a free installation service, and any user can find controlnet-depth-sdxl-1.0-small on GitHub to install. At the same time, huggingface.co provides the effect of controlnet-depth-sdxl-1.0-small install, users can directly use controlnet-depth-sdxl-1.0-small installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

controlnet-depth-sdxl-1.0-small install url in huggingface.co:

https://huggingface.co/diffusers/controlnet-depth-sdxl-1.0-small

Url of controlnet-depth-sdxl-1.0-small

controlnet-depth-sdxl-1.0-small huggingface.co Url

Provider of controlnet-depth-sdxl-1.0-small huggingface.co

diffusers
ORGANIZATIONS

Other API from diffusers

huggingface.co

Total runs: 46.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 22 2024
huggingface.co

Total runs: 1.7K
Run Growth: -445
Growth Rate: -25.90%
Updated:February 08 2023
huggingface.co

Total runs: 403
Run Growth: -35
Growth Rate: -8.68%
Updated:February 24 2025
huggingface.co

Total runs: 16
Run Growth: 3
Growth Rate: 18.75%
Updated:February 07 2024
huggingface.co

Total runs: 14
Run Growth: -13
Growth Rate: -92.86%
Updated:January 27 2023