liuhongwei-2026/dreamshaper-7
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

DreamShaper-7 — 昇腾 NPU 部署

多模态 · 文生图 · 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

验证环境

组件版本
torch2.9.0
torch-npu2.9.0.post1
diffusers0.33.0+
transformers4.57.6
CANN8.5.1
NPUAscend 910B4

快速开始

1. 克隆仓库

git clone https://atomgit.com/liuhongwei-2026/dreamshaper-7.git
cd dreamshaper-7

2. 安装依赖

pip install -r requirements.txt

3. 下载模型权重

从 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

4. 运行推理

# 基本用法(自动从 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-pathNone本地模型路径,不指定则从 HuggingFace Hub 下载
--prompt(见脚本)文本提示词
--negative-prompt""负面提示词
--outputdreamshaper_output.png输出图像路径
--devicenpu:0推理设备 (npu:0 / cpu)
--num-inference-steps25推理步数
--guidance-scale7.5引导系数
--seed42随机种子
--height512图像高度
--width512图像宽度

复现步骤

# 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     # 模型推理结果截图

License

  • 模型权重: CreativeML OpenRAIL-M
  • 本仓库代码: Apache License 2.0