🚀 TensorArt Stable Diffusion 3.5 Medium ControlNet Canny
本項目基於Stable Diffusion 3.5 Medium,結合ControlNet Canny技術,實現了強大的文本到圖像的生成能力。用戶可以通過輸入文本提示,生成高質量的圖像。
🚀 快速開始
本項目提供了兩種使用方式,分別基於不同的模型。以下是詳細的使用步驟和代碼示例。
使用StableDiffusion 3.5 Medium模型
import torch
from diffusers import StableDiffusion3ControlNetPipeline
from diffusers import SD3ControlNetModel
from diffusers.utils import load_image
controlnet = SD3ControlNetModel.from_pretrained("tensorart/SD3.5M-Controlnet-Canny")
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-3.5-medium",
controlnet=controlnet
)
pipe.to("cuda", torch.float16)
control_image = load_image("https://huggingface.co/tensorart/SD3.5M-Controlnet-Canny/resolve/main/asset/canny.png")
prompt = "An eye"
negative_prompt = "low quality, worst quality, deformed, distorted, disfigured, motion smear, motion artifacts, fused fingers, bad anatomy, weird hand, ugly, monochrome"
image = pipe(
prompt,
num_inference_steps=30,
negative_prompt=negative_prompt,
control_image=control_image,
guidance_scale=4.5,
controlnet_conditioning_scale=0.8
).images[0]
image.save('image.jpg')
使用TensorArt的SD3.5M Turbo模型
import torch
from diffusers import StableDiffusion3ControlNetPipeline
from diffusers import SD3ControlNetModel
from diffusers.utils import load_image
controlnet = SD3ControlNetModel.from_pretrained("tensorart/SD3.5M-Controlnet-Canny")
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
"tensorart/stable-diffusion-3.5-medium-turbo",
controlnet=controlnet
)
pipe.to("cuda", torch.float16)
control_image = load_image("https://huggingface.co/tensorart/SD3.5M-Controlnet-Canny/resolve/main/asset/canny.png")
prompt = "An eye"
negative_prompt = "low quality, worst quality, deformed, distorted, disfigured, motion smear, motion artifacts, fused fingers, bad anatomy, weird hand, ugly, monochrome"
image = pipe(
prompt,
num_inference_steps=8,
negative_prompt=negative_prompt,
control_image=control_image,
guidance_scale=1.5,
controlnet_conditioning_scale=0.8
).images[0]
image.save('image.jpg')
📄 許可證
本項目使用的許可證為 stabilityai-ai-community
,詳細信息請參考 LICENSE.md。
📞 聯繫我們
- 網站: https://tensor.art https://tusiart.com
- 開發者: TensorArt