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 分钟前
(论文速读)MoE-Adapters++: 过动态混合专家适配器实现更有效的视觉语言模型的持续学习
人工智能·自然语言处理·视觉语言模型·持续学习
数字冰雹4 分钟前
数字孪生如何重塑数据中心运维新范式
大数据·人工智能
handuoduo12347 分钟前
SITAN中avp必要性分析
人工智能·算法·机器学习
zl_vslam8 分钟前
SLAM中的非线性优-3D图优化之相对位姿Between Factor右扰动(八)
人工智能·算法·计算机视觉·3d
TextIn智能文档云平台10 分钟前
从散乱资料到智能知识库:基于TextIn与Coze的RAG实战
人工智能·pdf·知识库·rag·coze·文档解析
【建模先锋】10 分钟前
精品数据分享 | 锂电池数据集(七)同济大学电池数据集
深度学习·锂电池剩余寿命预测·锂电池数据集·寿命预测·数据集分享
C嘎嘎嵌入式开发11 分钟前
deepseek-r1大模型的本地部署
人工智能·python·神经网络·机器学习
翔云 OCR API19 分钟前
赋能文档的数字化智能处理:通用文字/文档/合同识别接口
开发语言·人工智能·python·计算机视觉·ocr
_codemonster22 分钟前
AI大模型入门到实战系列(五)上下文嵌入向量(contextualized embedding)
人工智能·深度学习·embedding
.又是新的一天.26 分钟前
AI+软件测试04(AI应用技巧)
软件测试·人工智能·ai+软件测试