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")
相关推荐
AAD555888998 小时前
【电力设备检测】YOLO11-LQEHead绝缘子缺陷检测与分类系统实现
人工智能·分类·数据挖掘
renhongxia18 小时前
学习基于数字孪生的质量预测与控制
人工智能·深度学习·学习·语言模型·自然语言处理·制造
Ulyanov8 小时前
高级可视化技术——让PyVista数据展示更专业
开发语言·前端·人工智能·python·tkinter·gui开发
koo3648 小时前
pytorch深度学习笔记16
pytorch·笔记·深度学习
昨夜见军贴06168 小时前
IACheck × AI审核赋能5G远程检测:实时视频传输质量
人工智能·5g
Coovally AI模型快速验证8 小时前
2026 CES 如何用“视觉”改变生活?机器的“视觉大脑”被点亮
人工智能·深度学习·算法·yolo·生活·无人机
用户5191495848458 小时前
深入解析CVE-2025-59528:Flowise中的高危远程代码执行漏洞
人工智能·aigc
洞见新研社8 小时前
新能源汽车2026前瞻,“量变”到“质变”的分水岭
人工智能
木卫二号Coding9 小时前
第七十五篇-分享+ComfyUI+SeedVR2+TTP放大+0损耗压缩+图片放大
人工智能
WitsMakeMen9 小时前
用矩阵实例具象化 RankMixer 核心机制
人工智能·线性代数·矩阵·llm