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")
相关推荐
万行9 分钟前
机器学习&第三章
人工智能·python·机器学习·数学建模·概率论
木卫四科技12 分钟前
DocETL 入门:让非结构化数据处理变得简单智能
人工智能·木卫四
玖日大大13 分钟前
OceanBase SeekDB:AI 原生数据库的技术革命与实践指南
数据库·人工智能·oceanbase
小润nature15 分钟前
Spec-Driven Development (SDD) 框架与开源 AI 智能体-意图的进化
人工智能·开源
后端小肥肠20 分钟前
复刻10W+爆款视频!我用Coze搭了个“人物故事”自动流水线,太香了!
人工智能·aigc·coze
轻竹办公PPT34 分钟前
2026 年工作计划 PPT 内容拆解,对比不同 AI 生成思路
人工智能·python·powerpoint
浔川python社40 分钟前
【版本更新提示】浔川 AI 翻译 v6.0 合规优化版已上线
人工智能
清 澜43 分钟前
c++高频知识点总结 第 1 章:语言基础与预处理
c++·人工智能·面试
OpenMiniServer1 小时前
AI全周期开发平台设计方案
人工智能
明月照山海-1 小时前
机器学习周报三十
人工智能·机器学习·计算机视觉