🚀 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