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")
相关推荐
掘金安东尼1 分钟前
ZeroClaw 是什么?一个 Rust 写的"轻量级 AI Agent 运行时"完整科普
人工智能
maxchen.cn5 分钟前
实时交互数字人解决方案深度剖析:以臻灵平台为例的商业价值与竞争力评估
大数据·人工智能
lwf0061646 分钟前
数据预处理(特征标准化)
人工智能·机器学习
前端达人8 分钟前
《AI 产品经理转型实战手册》介绍
人工智能·产品经理
网络工程小王10 分钟前
【DeepAgents简介】个人学习笔记
人工智能
一只AI打工虾的自我修养10 分钟前
DeepSeek V4 Hybrid Attention Architecture 技术解析
人工智能·ai·开源·aigc
格林威15 分钟前
面阵相机 vs 线阵相机:堡盟与大恒相机选型差异全解析 附C++ 实战演示
开发语言·c++·人工智能·数码相机·计算机视觉·视觉检测·工业相机
黎阳之光16 分钟前
视频孪生赋能智慧能源园区:黎阳之光打造全域数智化新标杆
大数据·人工智能·算法·安全·数字孪生
Jun62619 分钟前
yolo11-目标检测&官方模型测试
人工智能·python·目标检测
龙山云仓21 分钟前
智造驾驶舱 · 异常闭环决策中心
人工智能·机器学习