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")
相关推荐
FreeBuf_几秒前
恶意Rust组件与AI机器人利用CI/CD管道窃取开发者密钥
人工智能·ci/cd·rust
菜鸟‍1 分钟前
【论文学习】PDFNet:基于深度完整性先验与细粒度补丁策略的高精度二值图像分割
人工智能·深度学习·计算机视觉
大强同学1 分钟前
create-skills:帮你创建skills的技能
人工智能·ai编程
yhdata1 分钟前
一体式AR眼镜市场稳步上扬:现规模119.2亿元,未来六年年均增速20.4%锁定441.1亿元
大数据·网络·人工智能·ar
老邋遢2 分钟前
干货篇|02. 纯AI Coding商业应用
java·人工智能
Hardworking6662 分钟前
OpenClaw的特点、产品架构、市场机遇、安全风险
人工智能·安全·架构·智能体·openclaw
PHOSKEY3 分钟前
严守AI服务器冷凝板平面度基准,光子精密3D工业相机保障散热效能
人工智能
Dxy12393102166 分钟前
深度学习的优雅降温:PyTorch中CosineAnnealingLR的终极指南
人工智能·pytorch·深度学习
NOVAnet20236 分钟前
AI智能体OpenClaw实战:终端安全风险分析与防护实践
网络·人工智能·安全·网络安全·南凌科技
Seven凹凸Man9 分钟前
WorkBuddy(Claw)原型设计之Axhub实战篇
人工智能