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")
相关推荐
oak隔壁找我几秒前
大模型中参数中 topP(核采样)与 topK 参数的区别
人工智能
还是大剑师兰特3 分钟前
AI 航天领域20强
人工智能·思维导图·ai航天
AI即插即用13 分钟前
即插即用系列 | CVPR 2024 FADC:频域自适应空洞卷积,完美解决语义分割“网格效应”
图像处理·人工智能·深度学习·目标检测·计算机视觉·视觉检测
Sinnet-cloud14 分钟前
以AI算力基建赋能中国企业出海新征程 | 光环云香港亮相2025 GIS全球创新峰会
人工智能·gpu算力
Hui Baby14 分钟前
STT语音转文字探秘
人工智能·语音识别
张彦峰ZYF15 分钟前
AI赋能原则9解读思考:高智能 AI 时代的人类生存与发展之道-协同进化
人工智能·ai·ai赋能与落地
优爱蛋白16 分钟前
IL-21:后Th1/Th2时代的免疫新星
java·服务器·前端·人工智能·健康医疗
深圳佛手16 分钟前
LangChain 提供的搜素工具SerpAPIWrapper介绍
开发语言·人工智能·python
Dreamshop_AI20 分钟前
电商视觉时代:如何用Dreamshop重构“人-货-场”?
大数据·人工智能·经验分享·ai作画·aigc
渡我白衣22 分钟前
计算机组成原理(4):计算机的层次结构与工作原理
运维·c语言·网络·c++·人工智能·笔记·硬件架构