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")
相关推荐
维克兜率天8 分钟前
【维克】弹性策略:用“乖离率“捕捉超跌反弹
android·开发语言·python·深度学习·kotlin·量化
audyxiao00117 分钟前
让大语言模型先读懂外部事件:一种文本增强与正则扩散对齐的多模态时序预测框架
人工智能·语言模型·多模态·时间序列
小范的技术工坊19 分钟前
大模型蒸馏
人工智能·算法·数据挖掘·大模型
程序员清风25 分钟前
Java 智能体开发:从对话接口到任务执行
java·人工智能·python
ai小陈36 分钟前
GPU服务器租用容器实战:Docker数据卷持久化与安全重建
服务器·人工智能·安全·docker·ai·gpu算力
打工仔折腾 AI41 分钟前
从零写一个CAD 02:实体容器、Esc取消与键盘失灵的排查
人工智能·后端·python·性能优化
QYR-分析1 小时前
内燃机配套核心部件:汽车摇臂市场稳健增长,5.0% CAGR 背后的产业博弈
人工智能·汽车
千里码aicood1 小时前
基于CNN的陕西降雨量气象分析
人工智能·神经网络·cnn
码云之上1 小时前
从搜索框到 Agent:Chatbot 联网搜索的技术演进
人工智能·架构·前端框架