Stable Diffusion demo脚本

stable_diffusion-2-1

cpp 复制代码
import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler

model_id = "/mnt/Datasets/Opensource_pretrained_models/Stable_Diffusion/stable_diffusion-2-1/"

# Use the DPMSolverMultistepScheduler (DPM-Solver++) scheduler here instead
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")

prompt = "High quality, Smooth, texture-filtered surface highlighting the bold <<Frank & Charlie>> text with enhanced clarity and contrast."
image = pipe(prompt).images[0]
    
image.save("v2.1smooth.png")

stable-diffusion-v1-4

cpp 复制代码
import torch
from diffusers import StableDiffusionPipeline

model_id = "/mnt/Datasets/Opensource_pretrained_models/Stable_Diffusion/stable-diffusion-v1-4/"
device = "cuda"


pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to(device)

prompt = "Weathered wood with visible cracks and textured grain in varying brown tones"
image = pipe(prompt).images[0]  
    
image.save("output.png")
相关推荐
甲维斯3 分钟前
你们要测的啊!GPT5.6版3D台球
人工智能
海盗12343 分钟前
微软技术周报 · 2026-08-11~2026-08-18
人工智能·microsoft·.net
Ricardo-Yang8 分钟前
无人机单目深度估计测试:ZipDepth 与 AerialMetric
人工智能·算法·机器学习·计算机视觉·无人机
Henry-SAP9 分钟前
具身智能新突破:开源生态与IPO热潮
人工智能·云原生·sap·erp
其实防守也摸鱼12 分钟前
红队技能总结导图:从入门到精通的完整知识体系
开发语言·人工智能·学习·安全·web安全
饼干哥哥27 分钟前
重生之我是导演:爆改成「牛来版」黑客帝国?附3D预演台保姆级教程!
人工智能·后端·深度学习
Bruce_Liuxiaowei43 分钟前
自动化渗透测试——用AI构建自动化渗透测试流程
运维·人工智能·自动化
AI导出鸭1 小时前
怎么让Claude做表格?AI导出鸭苹果版将Claude输出的Markdown表格或结构化列表智能解析为二维数据,一键导出Excel/Word标准表格。
人工智能·chatgpt·word·excel·ai导出鸭
ACP广源盛139246256731 小时前
Qwen3.8‑2.4T 开源落地@ACP#国产 MoE 大模型私有化部署中 MST 多屏转换芯片 GSV2231 硬件价值与应用场景
大数据·数据库·人工智能·嵌入式硬件
夏雪coding1 小时前
openpyxl 对账实战:金额浮点、前导零丢失、20 位单号科学计数法
人工智能·后端