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")
相关推荐
安全指北针2 小时前
AI检测 vs 传统SIEM:2026年安全运营效率实测对比
人工智能·安全
SilentSamsara2 小时前
模型评估与超参调优:交叉验证、Optuna 与模型选择策略
人工智能·python·深度学习·机器学习·青少年编程
一次旅行2 小时前
【AI工具】Odysseus:GitHub 6万星自托管AI工作空间,隐私优先的本地化AI体验
人工智能·github
网络研究院2 小时前
利用人工智能破解中世纪密码
人工智能·研究·历史·语言·情报
东方佑2 小时前
如何证明自然语言是条件随机、递归自指后的分形
人工智能
叫我:松哥2 小时前
基于LSTM与ARIMA的城市空气质量分析与预测系统
人工智能·python·rnn·算法·机器学习·flask·lstm
RestCloud2 小时前
Claude Code适配故障频发,企业AI业务稳定,离不开AI网关兜底
人工智能·claude·ai大模型·ipaas·minimax·ai网关
爱看科技2 小时前
苹果WWDC26引爆全端AI产品,Meta/WIMI微美全息加速抢滩XR眼镜硬件市场
人工智能·xr
广州智造2 小时前
如何在HyperMesh的两片相邻体单元间批量创建RBE3实现载荷传递
人工智能·设计·建模·网格·网格划分·hypermesh·前处理
CodeSheep程序羊2 小时前
宇树科技,即将上市!
java·c语言·c++·人工智能·python·科技·硬件工程