Model reference · open weights
stable-diffusion-3.5-large-controlnet-canny is an open-weight image model from stabilityai. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | Stability AI |
|---|---|
| Published under | stabilityai |
| Type | Image models |
| Task | Text→image |
| Parameters (lead) | 2.2B |
| Runs with | diffusers |
| Released | 2024-11-25 |
| Popularity | 1k downloads / month |
| Licence | Commercial licence needed |
About
This repository provides the Canny ControlNet for Stable Diffusion 3.5 Large..
Please note: This model is released under the Stability Community License. Visit Stability AI to learn or contact us for commercial licensing details.
Here are the key components of the license:
For organizations with annual revenue more than $1M, please contact us here to inquire about an Enterprise License.
Install the repo:
git clone git@github.com:Stability-AI/sd3.5.git
pip install -r requirements.txt
Then, download the models and sample images like so:
input/sample_cond.png
models/clip_g.safetensors
models/clip_l.safetensors
models/t5xxl.safetensors
models/sd3.5_large.safetensors
models/canny_8b.safetensors
and then you can run
python sd3_infer.py --controlnet_ckpt models/canny_8b.safetensors --controlnet_cond_image input/sample_cond.png --prompt "An adorable fluffy pastel creature"
Which should give you an image like below:
Make sure you upgrade to the latest version of diffusers: pip install -U diffusers. And then you can run:
import torch
from diffusers import StableDiffusion3ControlNetPipeline, SD3ControlNetModel
from diffusers.utils import load_image
from diffusers.image_processor import VaeImageProcessor
class SD3CannyImageProcessor(VaeImageProcessor):
def __init__(self):
super().__init__(do_normalize=False)
def preprocess(self, image, **kwargs):
image = super().preprocess(image, **kwargs)
image = image * 255 * 0.5 + 0.5
return image
def postprocess(self, image, do_denormalize=True, **kwargs):
do_denormalize = [True] * image.shape[0]
image = super().postprocess(image, **kwargs, do_denormalize=do_denormalize)
return image
controlnet = SD3ControlNetModel.from_pretrained("stabilityai/stable-diffusion-3.5-large-controlnet-canny", torch_dtype=torch.float16)
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-3.5-large",
controlnet=controlnet,
torch_dtype=torch.float16
).to("cuda")
pipe.image_processor = SD3CannyImageProcessor()
control_image = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/canny.png")
prompt = "A Night time photo taken by Leica M11, portrait of a Japanese woman in a kimono, looking at the camera, Cherry blossoms"
generator = torch.Generator(device="cpu").manual_seed(0)
image = pipe(
prompt,
control_image=control_image,
controlnet_conditioning_scale=1.0,
guidance_scale=3.5,
num_inference_steps=60,
generator=generator,
max_sequence_length=77,
).images[0]
image.save(f'canny-8b.jpg')
An input image can be preprocessed for control use following the code snippet below. SD3.5 does not implement this behavior, so we recommend doing so in an external script beforehand.
import torchvision.transforms.functional as F
# assuming img is a PIL image
img = F.to_tensor(img)
img = cv2.cvtColor(img.transpose(1, 2, 0), cv2.COLOR_RGB2GRAY)
img = cv2.Canny(img, 100, 200)
--text_encoder_device to load the text encoders directly to VRAM, which can speed up the full inference loop at the cost of extra VRAM usage.All uses of the model must be in accordance with our Acceptable Use Policy.
The model was not trained to be factual or true representations of people or events. As such, using the model to generate such content is out-of-scope of the abilities of this model.
These models were trained on a wide variety of data, including synthetic data and filtered publicly available data.
We believe in safe, responsible AI practices and take deliberate measures to ensure Integrity starts at the early stages of development. This means we have taken and continue to take reasonable steps to prevent the misuse of Stable Diffusion 3.5 by bad actors. For more information about our approach to Safety please visit our Safety page.
Our integrity evaluation methods include structured evaluations and red-teaming testing for certain harms. Testing was conducted primarily in English and may not cover all possible harms.
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys stable-diffusion-3-5-large-controlnet-canny for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (stable-diffusion-3-5-large-controlnet-canny below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/images/generations \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"stable-diffusion-3-5-large-controlnet-canny","prompt":"a red bicycle","size":"1024x1024"}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.