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")
相关推荐
fanstuck4 分钟前
AI 回答得头头是道,怎么一查原文,条号就对不上了?
人工智能·aigc·agent
硅谷秋水8 分钟前
BAAI的PhysCapBench分析
人工智能·机器学习·机器人
Dawson Zhu20 分钟前
【多平台适配③】Ascend NPU昇腾适配:CANN软件栈与算子迁移实战
人工智能·语言模型·架构·aigc·agi
民乐团扒谱机42 分钟前
【超详细】基频音高提取算法之SWIPE 算法深度解析:频谱匹配的精度极限与工程边界
人工智能·算法
SelectDB1 小时前
数据湖的数据怎么直接查?Apache Doris 免搬运查询 Iceberg、Paimon、Lance 与 AI 检索实战
人工智能
星恒随风1 小时前
从0实现C++ AI大模型接入SDK(四):大模型API接入、公共数据结构设计与日志库封装
linux·服务器·数据结构·c++·人工智能
SelectDB1 小时前
网易云音乐基于 Apache Doris 的 AI 数据统一查询与治理实践
人工智能
火山引擎开发者社区2 小时前
一个向量库,两种检索:VikingDB 关键词检索实践
人工智能
火山引擎开发者社区2 小时前
火山引擎携手南开大学:两个 AI 智能体,让美学研究走进日常对话
人工智能
WT同学3 小时前
RAG 系统工程化实践(深化篇):从"能用"到"好用"的进阶之路
人工智能