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")
相关推荐
算了吧9569几秒前
2026年GEO服务商深度测评:答序科技“诊断型”全栈闭环的技术架构与行业价值
大数据·人工智能
爱学堂IT分享8 分钟前
Text2SQL智能体基础到实战 - 网易云课堂
人工智能
MatrixOrigin10 分钟前
矩阵起源中标外研社“多模态数据智能平台和智能体开发项目“
人工智能·ai-native·矩阵起源·外研社
leoZ23112 分钟前
AI+前端提效-12 AI辅助前端性能优化与监控:从开发到线上全流程提效
前端·人工智能·神经网络·自然语言处理·性能优化·keras·知识图谱
拓人间精准客13 分钟前
数据即生产力:全维度销售线索如何以“多维数据优势“重塑 B2B 获客格局
大数据·人工智能·tob
byte轻骑兵14 分钟前
【BlueZ 】用户态入口:main.c 核心函数与程序启动流程
linux·人工智能·bluez·电脑蓝牙·嵌入式蓝牙
大模型真好玩15 分钟前
DeepSeek Harness 入门很简单(一)——认识DeepSeek Harness并安装
人工智能·agent·deepseek
j7~16 分钟前
【AI 应用 -- 白话大模型(篇八)】《从零系统学习 AI Skill|起源发展、文件结构、编写原则、机制原理与项目实战案例》
人工智能·skill·编写skill实战·opencode安装·skill社区
老纪的技术唠嗑局17 分钟前
被自己的模型吓到后,OpenAI 终于踩下了刹车
人工智能
JeJe同学18 分钟前
ONNX 的核心原理
人工智能·onnx