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")
相关推荐
zandy10115 分钟前
世界模型产业主体梳理:具身大脑、物理仿真与数字场景的多元实践
大数据·人工智能
鬼手爱剪辑7 分钟前
视频擦除全流程,从擦除原理、开源软件到工具选择
人工智能
GPUStack10 分钟前
基于海光的 GPUStack 部署方案指导——以 Qwen3.6-27B 为例
人工智能·开源
lexiangqicheng15 分钟前
14-AI智能管家JSBridge深度问答
人工智能
挖掘狂人16 分钟前
AI 一天写的代码多了 30%,软件却没多出一个
人工智能·ai编程
小玮看世界17 分钟前
【推测文】AI陪伴赛道的下一程:合规倒逼、组织重构与“反迎合”变成新护城河
人工智能
for_ever_love__18 分钟前
LangChain 批量调用与并发控制:batch、abatch 与速率限制
人工智能·langchain·异步·config·invoke·abatch
码流子19 分钟前
高速场景视频接入:GB/T 28181 级联与 RTSP 取流,一条链路讲清楚
大数据·数据库·人工智能·物联网·音视频
卿卿的产品经理日记24 分钟前
【AI产品经理实战】Day 37|拆开 JSON 与 EXE:数据都有格式
人工智能·笔记·python·json·产品经理
yunni824 分钟前
政企AI落地避坑:敏感数据不出域,安全需求优先本地化部署
人工智能·安全