dreamshaper-7 是一个基于 Stable Diffusion 1.5 的文生图模型,可将文本提示词生成高质量图像。本仓库将其适配至 Ascend NPU(昇腾 910B)运行。
.cuda() / torch.cuda 调用已移除,模型和所有张量运行在 npu:0 设备上torch.float16 半精度推理,开启 attention slicing 优化内存# 使用提示词文件
ASCEND_RT_VISIBLE_DEVICES=1 python3 inference.py --img examples/prompt.txt
# 使用 --prompt 参数
ASCEND_RT_VISIBLE_DEVICES=1 python3 inference.py --prompt "a cat wearing a hat, digital art"ASCEND_RT_VISIBLE_DEVICES=1 python3 inference.py --mode server --port 8782# 测试
curl -s -F prompt="a cat" http://127.0.0.1:8782/predictmodel_weights/Lykon/dreamshaper-7/https://hf-mirror.com/Lykon/dreamshaper-7/{
"model": "Lykon/dreamshaper-7",
"device": "npu:0",
"status": "success",
"elapsed_ms": 12345.67,
"prompt": "a majestic castle...",
"image_path": "results/output_1234567890.png",
"image_size": "512x512",
"num_inference_steps": 25,
"seed": 42
}