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")
相关推荐
AI绘画哇哒哒4 分钟前
【收藏必看】大模型智能体六大设计模式详解:从ReAct到Agentic RAG,构建可靠AI系统
人工智能·学习·ai·语言模型·程序员·产品经理·转行
CNRio1 小时前
人工智能基础架构与算力之3 Transformer 架构深度解析:从注意力机制到算力适配演进
人工智能·深度学习·transformer
qy-ll1 小时前
深度学习——CNN入门
人工智能·深度学习·cnn
青瓷程序设计4 小时前
动物识别系统【最新版】Python+TensorFlow+Vue3+Django+人工智能+深度学习+卷积神经网络算法
人工智能·python·深度学习
F_D_Z5 小时前
数据集相关类代码回顾理解 | sns.distplot\%matplotlib inline\sns.scatterplot
python·深度学习·matplotlib
金智维科技官方6 小时前
RPA财务机器人为企业高质量发展注入动能
人工智能·机器人·rpa·财务
沫儿笙6 小时前
安川机器人tag焊接怎么节省保护气
人工智能·物联网·机器人
2501_941147426 小时前
人工智能赋能智慧教育互联网应用:智能学习与教育管理优化实践探索》
人工智能
阿龙AI日记6 小时前
详解Transformer04:Decoder的结构
人工智能·深度学习·自然语言处理
爱写代码的小朋友6 小时前
“数字镜像”与认知负能者:生成式AI个性化学习支持者的协同构建与伦理规制研究
人工智能