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")
相关推荐
marteker4 分钟前
奥利奥制造商亿滋国际如何借助人工智能重新思考零食营销
人工智能·搜索引擎
泰迪智能科技4 分钟前
分享|2025年广东水利电力职业技术学院泰迪数据智能产业学院订单班结业典礼圆满结束
大数据·人工智能
宁大小白7 分钟前
pythonstudy Day45
开发语言·python·深度学习
算法与编程之美7 分钟前
探索不同的损失函数对分类精度的影响.
人工智能·算法·机器学习·分类·数据挖掘
qq_4308558814 分钟前
线代第五章线性方程组第四节:相似矩阵的概念和性质
人工智能·机器学习
bluetata19 分钟前
Spring AI 使用 AWS Amazon Nova 模型
人工智能·spring·aws
audyxiao00128 分钟前
智慧医疗顶会MICCAI 2025获奖论文精彩看点
人工智能·智慧医疗顶会·miccai
Android技术之家29 分钟前
2025年度Android行业总结:AI驱动生态重构,跨端融合开启新篇
android·人工智能·重构
easy_coder29 分钟前
从“未知故障”到“自治诊断”:基于双路召回与RAG的智能诊断系统构建
人工智能·云原生·云计算
中科天工33 分钟前
如何实现工业AI在智能制造中的应用?
大数据·人工智能·智能