diffusers / controlnet-zoe-depth-sdxl-1.0

huggingface.co
Total runs: 2.9K
24-hour runs: 0
7-day runs: -19
30-day runs: 1.3K
Model's Last Updated: 2024年8月22日
text-to-image

Introduction of controlnet-zoe-depth-sdxl-1.0

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

SDXL-controlnet: Zoe-Depth

These are ControlNet weights trained on stabilityai/stable-diffusion-xl-base-1.0 with zoe depth conditioning. Zoe-depth is an open-source SOTA depth estimation model which produces high-quality depth maps, which are better suited for conditioning.

You can find some example images in the following.

images_0)

images_2

images_3

Usage

Make sure first to install the libraries:

pip install accelerate transformers safetensors diffusers

And then setup the zoe-depth model

import torch
import matplotlib
import matplotlib.cm
import numpy as np

torch.hub.help("intel-isl/MiDaS", "DPT_BEiT_L_384", force_reload=True)  # Triggers fresh download of MiDaS repo
model_zoe_n = torch.hub.load("isl-org/ZoeDepth", "ZoeD_NK", pretrained=True).eval()
model_zoe_n = model_zoe_n.to("cuda")


def colorize(value, vmin=None, vmax=None, cmap='gray_r', invalid_val=-99, invalid_mask=None, background_color=(128, 128, 128, 255), gamma_corrected=False, value_transform=None):
    if isinstance(value, torch.Tensor):
        value = value.detach().cpu().numpy()

    value = value.squeeze()
    if invalid_mask is None:
        invalid_mask = value == invalid_val
    mask = np.logical_not(invalid_mask)

    # normalize
    vmin = np.percentile(value[mask],2) if vmin is None else vmin
    vmax = np.percentile(value[mask],85) if vmax is None else vmax
    if vmin != vmax:
        value = (value - vmin) / (vmax - vmin)  # vmin..vmax
    else:
        # Avoid 0-division
        value = value * 0.

    # squeeze last dim if it exists
    # grey out the invalid values

    value[invalid_mask] = np.nan
    cmapper = matplotlib.cm.get_cmap(cmap)
    if value_transform:
        value = value_transform(value)
        # value = value / value.max()
    value = cmapper(value, bytes=True)  # (nxmx4)

    # img = value[:, :, :]
    img = value[...]
    img[invalid_mask] = background_color

    # gamma correction
    img = img / 255
    img = np.power(img, 2.2)
    img = img * 255
    img = img.astype(np.uint8)
    img = Image.fromarray(img)
    return img


def get_zoe_depth_map(image):
    with torch.autocast("cuda", enabled=True):
        depth = model_zoe_n.infer_pil(image)
    depth = colorize(depth, cmap="gray_r")
    return depth

Now we're ready to go:

import torch
import numpy as np
from PIL import Image

from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
from diffusers.utils import load_image

controlnet = ControlNetModel.from_pretrained(
  "diffusers/controlnet-zoe-depth-sdxl-1.0",
  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()


prompt = "pixel-art margot robbie as barbie, in a coupé . low-res, blocky, pixel art style, 8-bit graphics"
negative_prompt = "sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic"
image = load_image("https://media.vogue.fr/photos/62bf04b69a57673c725432f3/3:2/w_1793,h_1195,c_limit/rev-1-Barbie-InstaVert_High_Res_JPEG.jpeg")

controlnet_conditioning_scale = 0.55

depth_image = get_zoe_depth_map(image).resize((1088, 896))

generator = torch.Generator("cuda").manual_seed(978364352)
images = pipe(
  prompt, image=depth_image, num_inference_steps=50, controlnet_conditioning_scale=controlnet_conditioning_scale, generator=generator
).images
images[0]

images[0].save(f"pixel-barbie.png")

images_1)

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

Training

Our training script was built on top of the official training script that we provide here .

Training data and Compute

The model is trained on 3M image-text pairs from LAION-Aesthetics V2. The model is trained for 700 GPU hours on 80GB A100 GPUs.

Batch size

Data parallel with a single gpu batch size of 8 for a total batch size of 256.

Hyper Parameters

Constant learning rate of 1e-5.

Mixed precision

fp16

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

2.9K
Total runs
0
24-hour runs
54
3-day runs
-19
7-day runs
1.3K
30-day runs

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

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

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

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

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

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

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

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

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

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

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

controlnet-zoe-depth-sdxl-1.0 install

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

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

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

Url of controlnet-zoe-depth-sdxl-1.0

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

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

diffusers
ORGANIZATIONS

Other API from diffusers

huggingface.co

Total runs: 5.3K
Run Growth: 0
Growth Rate: 0.00%
Updated: 2024年10月22日
huggingface.co

Total runs: 4.0K
Run Growth: -1.5K
Growth Rate: -39.10%
Updated: 2023年2月8日
huggingface.co

Total runs: 463
Run Growth: 146
Growth Rate: 31.53%
Updated: 2025年2月23日
huggingface.co

Total runs: 34
Run Growth: 25
Growth Rate: 75.76%
Updated: 2023年1月27日
huggingface.co

Total runs: 12
Run Growth: -4
Growth Rate: -30.77%
Updated: 2024年2月6日
huggingface.co

Total runs: 2
Run Growth: 0
Growth Rate: 0.00%
Updated: 2025年3月11日
huggingface.co

Total runs: 0
Run Growth: -1
Growth Rate: 0.00%
Updated: 2023年3月14日