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")
相关推荐
我要学脑机3 分钟前
基于常微分方程的神经网络(Neural ODE)
人工智能·深度学习·神经网络
有颜有货14 分钟前
2025汽车制造企业数字化转型路径参考
人工智能·汽车·制造·数字化转型
阿星AI工作室17 分钟前
小白也能用AI开发「小红书自动归档多维表格」采集神器,躺平整理笔记真香
人工智能
云天徽上18 分钟前
【数据可视化-42】杂货库存数据集可视化分析
人工智能·机器学习·信息可视化·数据挖掘·数据分析
大模型真好玩21 分钟前
初学者必看大模型微调指南:Unsloth官方微调技巧大公开!
人工智能·python
自由随风飘29 分钟前
机器学习第三篇 模型评估(交叉验证)
人工智能·机器学习
vocal29 分钟前
谷歌第七版Prompt Engineering—第三部分
人工智能·后端
ConardLi39 分钟前
要给大家泼盆冷水了,使用 MCP 绝对不容忽视的一个问题!
前端·人工智能·后端
阿里云大数据AI技术43 分钟前
PAI Model Gallery 支持云上一键部署 Qwen3 全尺寸模型
人工智能·llm
烟锁池塘柳044 分钟前
【计算机视觉】Bayer Pattern与Demosaic算法详解:从传感器原始数据到彩色图像
人工智能·深度学习·计算机视觉