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")
相关推荐
THMAIL7 分钟前
深度学习从入门到精通 - LSTM与GRU深度剖析:破解长序列记忆遗忘困境
人工智能·python·深度学习·算法·机器学习·逻辑回归·lstm
Gyoku Mint10 分钟前
NLP×第六卷:她给记忆加了筛子——LSTM与GRU的贴靠机制
人工智能·深度学习·神经网络·语言模型·自然语言处理·gru·lstm
YF云飞1 小时前
数据仓库进化:Agent驱动数智化新范式
数据仓库·人工智能·ai
ningmengjing_1 小时前
理解损失函数:机器学习的指南针与裁判
人工智能·深度学习·机器学习
程序猿炎义1 小时前
【NVIDIA AIQ】自定义函数实践
人工智能·python·学习
小陈phd2 小时前
高级RAG策略学习(四)——上下文窗口增强检索RAG
人工智能·学习·langchain
居然JuRan2 小时前
阿里云多模态大模型岗三面面经
人工智能
THMAIL2 小时前
深度学习从入门到精通 - BERT与预训练模型:NLP领域的核弹级技术详解
人工智能·python·深度学习·自然语言处理·性能优化·bert
nju_spy2 小时前
Kaggle - LLM Science Exam 大模型做科学选择题
人工智能·机器学习·大模型·rag·南京大学·gpu分布计算·wikipedia 维基百科
relis2 小时前
解密llama.cpp中的batch与ubatch:深度学习推理优化的内存艺术
深度学习·batch·llama