多模态 · 文生图 · Stable Diffusion 1.5
Lykon/dreamshaper-7 是基于 runwayml/stable-diffusion-v1-5 微调的 Stable Diffusion 文生图模型,参数量约 0.9B。本仓库提供在 华为昇腾 NPU(Ascend 910B/910C)上的部署方案,使用 diffusers + torch_npu 实现端到端推理。
| 项目 | 内容 |
|---|---|
| 模型来源 | Lykon/dreamshaper-7 |
| 镜像来源 | hf_mirrors/Lykon/dreamshaper-7 |
| 模型类型 | Stable Diffusion 1.5 (Text-to-Image) |
| 参数量 | ~0.9B |
| 精度 | FP16 |
| 框架 | PyTorch + diffusers |
| 适配状态 | ✅ 成功 |
| 适配时间 | 2026-08-23 |
| 组件 | 版本 |
|---|---|
| torch | 2.9.0 |
| torch-npu | 2.9.0.post1 |
| diffusers | 0.33.0+ |
| transformers | 4.57.6 |
| CANN | 8.5.1 |
| NPU | Ascend 910B4 |
git clone https://atomgit.com/liuhongwei-2026/dreamshaper-7.git
cd dreamshaper-7pip install -r requirements.txt从 HuggingFace 镜像站拉取:
# 方式一:使用 HuggingFace Hub(自动下载到缓存)
# 脚本会自动从 hf-mirror 或 HuggingFace Hub 拉取
# 方式二:从 AtomGit 镜像克隆(推荐,国内速度更快)
git lfs install
git clone https://atomgit.com/hf_mirrors/Lykon/dreamshaper-7.git /path/to/models/Lykon/dreamshaper-7# 基本用法(自动从 HuggingFace 下载)
python3 inference.py --prompt "a cat wearing a hat, digital art" --output cat.png
# 指定本地模型路径(推荐)
python3 inference.py \
--model-path /path/to/models/Lykon/dreamshaper-7 \
--prompt "portrait photo of a girl, cyberpunk city, vibrant colors, high quality" \
--output dreamshaper_output.png
# 自定义参数
python3 inference.py \
--prompt "beautiful landscape, mountains, sunset, highly detailed" \
--negative-prompt "ugly, blurry, low quality" \
--output landscape.png \
--num-inference-steps 30 \
--guidance-scale 7.5 \
--seed 12345 \
--height 512 \
--width 512| 参数 | 默认值 | 说明 |
|---|---|---|
--model-path | None | 本地模型路径,不指定则从 HuggingFace Hub 下载 |
--prompt | (见脚本) | 文本提示词 |
--negative-prompt | "" | 负面提示词 |
--output | dreamshaper_output.png | 输出图像路径 |
--device | npu:0 | 推理设备 (npu:0 / cpu) |
--num-inference-steps | 25 | 推理步数 |
--guidance-scale | 7.5 | 引导系数 |
--seed | 42 | 随机种子 |
--height | 512 | 图像高度 |
--width | 512 | 图像宽度 |
# 1. 安装依赖
pip install -r requirements.txt
# 2. 拉取模型权重
git lfs install
git clone https://atomgit.com/hf_mirrors/Lykon/dreamshaper-7.git /path/to/models/Lykon/dreamshaper-7
# 3. 运行推理
python3 inference.py \
--model-path /path/to/models/Lykon/dreamshaper-7 \
--prompt "portrait photo of muscular bearded guy in a worn mech suit, light bokeh, intricate, steel metal, elegant, sharp focus, soft lighting, vibrant colors" \
--output result.png \
--seed 33 \
--num-inference-steps 25
# 4. 验证输出
ls -la result.png| 指标 | 数值 |
|---|---|
| 推理步数 | 25 |
| 输出分辨率 | 512×512 |
| 平均延迟 | 待实测 |
| 峰值显存 | 待实测 |
性能数据将在实际昇腾 910B4 环境验证后更新。
dreamshaper-7/
├── inference.py # 推理脚本
├── README.md # 部署说明文档
├── requirements.txt # 环境依赖清单
└── assets/ # 截图素材文件夹
├── agent_workflow.png # 智能体工作流截图
├── npu_device_call.png # NPU 调用截图
└── model_result.png # 模型推理结果截图