Stable Diffusion 3.5 本地部署指南:从安装到标题解决,一站式搞定!
SD3.5环境设置及标题解决Stable Diffusion 3.5 作为AI绘画领域的重磅升级,以其强大的图像天生能力和灵活的本地部署特性,吸引了无数创作者。本指南将手把手带你完成从环境设置到模型运行的完备流程,并针对常见标题提供解决方案,助你轻松开启AI艺术创作之旅!
Stable Diffusion 3.5(简称SD3.5)是由Stability AI推出的最新一代图像天生模型,是Stable Diffusion系列的重要升级版本。
SD3.5包含三个主要版本:
[*] Stable Diffusion 3.5 Large:参数目为80亿,支持天生100万像素(1MP)的高分辨率图像,适合专业用户和对图像质量有较高要求的场景。
[*] Stable Diffusion 3.5 Large Turbo:基于Large版本优化,采用对抗性扩散蒸馏(ADD)技能,显著提高了天生速率,同时保持高质量输出。
[*] Stable Diffusion 3.5 Medium:参数目为25亿,实用于中平分辨率需求的用户,如天生40万像素(0.4MP)的图像。
SD3.5在多个方面进行了显著改:
[*] 图像质量和细节:通过增长模型参数目,提升了图像分辨率上限至2048x2048,并改善了细节体现和真实感。
[*] 提示词匹配度:优化了对复杂提示词的理解能力,能够更准确地天生符实用户需求的图像。
[*] 速率提升:Large Turbo版本通过技能优化,大幅缩短了天生时间,适合需要快速天生大量图像的用户。
[*] 多模态支持:支持多种视觉元素的整合,解决了早期版本中复杂细节和多元素集成的限制标题。
这份完备版的SD整合包已经上传CSDN,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【包管100%免费】
https://i-blog.csdnimg.cn/direct/46cc077091e341748859f105d8d1b90e.png
1.环境设置
[*] 创建虚环境
conda create -n sd3.5 python=3.10
[*] Pytorch(>2.0)
conda install pytorch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 pytorch-cuda=12.1 -c pytorch -c nvidia
[*] Jupyter能利用Anaconda虚环境
conda install ipykernel python -m ipykernel install --user --name sd3.5 --display-name "SD3.5"
[*] 安装transformer和tokenizer
pip install transformers==4.38.2 pip install tokenizers==0.15.2
[*] 安装最新版本的diffuser
pip install -U diffusers
[*] 安装量化库节约VRAM GPUs
pip install bitsandbytes
[*] 安装sentencepiece
pip install sentencepiece
[*] 根据项目需要安装其他库
pip install matplotlib pip install numpy==1.26.4 # 降级,否则有些时候会报错 pip install accelerate pip install protobuf==3.19.0
2.报错解决
如果报错:Exception: data did not match any variant of untagged enum PyPreTokenizerTypeWrapper at line 960 column 3降级解决
pip install transformers==4.38.2 pip install tokenizers==0.15.2
**如果报错ValueError: Cannot instantiate this tokenizer from a slow version. If it’s based on sentencepiece, make sure you have sentencepiece installed.**安装sentencepiece:
pip install sentencepiece
**如果报错:ValueError: The current PyTorch version does not support the scaled_dot_product_attention function.**解决:安装高于Pytorch>2.0
如果报错:T5Converter requires the protobuf library but it was not found in your environment. Checkout the instructions on the
解决:
pip install protobuf==3.19.0
3.实测
[*]官网例子:
local_path = "/home/aic/diffusion_models/stable-diffusion-3.5-large/" pipe = StableDiffusion3Pipeline.from_pretrained(local_path, torch_dtype=torch.bfloat16) pipe = pipe.to("cuda") image = pipe( "A capybara holding a sign that reads Hello World", num_inference_steps=28, guidance_scale=3.5, ).images image.save("capybara.png")
https://i-blog.csdnimg.cn/img_convert/15da43115198bc70677418330de09088.png
[*] 自界说例子
“一名古代风格的中国女学生坐在当代的计算机课堂里面学习编程”
prompts:“An ancient-style Chinese female student sitting in a modern computer classroom learning programming, focused eyes, traditional Hanfu attire, modern technology, code editor, keyboard, mouse, fusion of digital age and traditional aesthetics, rich in detail, high-definition quality.”
prompts="An ancient-style Chinese female student sitting in a modern computer classroom learning programming, focused eyes, traditional Hanfu attire, modern technology, code editor, keyboard, mouse, fusion of digital age and traditional aesthetics, rich in detail, high-definition quality." image = pipe( prompt=prompt, num_inference_steps=28, guidance_scale=4.5, max_sequence_length=512, ).images image.save("girls.png") plt.imshow(plt.imread("girls.png")) plt.axis('off')# 不显示坐标轴 display(plt.gcf())
https://i-blog.csdnimg.cn/img_convert/240fe6946850dd7addfa3038ee4c900c.png
这份完备版的SD整合包已经上传CSDN,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【包管100%免费】
https://i-blog.csdnimg.cn/direct/46cc077091e341748859f105d8d1b90e.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]