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")
相关推荐
半个落月1 小时前
从 Tokenization 到 Embedding:用 Node.js 搞懂大模型为什么先“分词”再“向量化”
人工智能·node.js
vanuan1 小时前
MCP协议实战(Java版):用Spring Boot让AI直接查你的数据库
人工智能
雪隐1 小时前
个人电脑玩AI-06让5060 Ti给你打工——不光能画画,Qwen3-TTS还能学人说话,连我老板都信了!
人工智能·后端·python
Coffeeee2 小时前
帮你快速理解AI Agent之我想招个Android实习生
android·人工智能·agent
新新技术迷2 小时前
AI聊天自动跟随滚动,附回到底部按钮
人工智能
先锋部队2 小时前
用Web Worker解析AI返回的大文本不卡UI
人工智能
把你拉进白名单2 小时前
8.OpenClaw源码解析——三层洋葱重试
人工智能·llm·agent
用户632415031782 小时前
拖文档进AI对话框解析,前端要处理哪些脏活
人工智能
姗姗来迟了2 小时前
AI回答里的引用来源卡片,前端怎么做
人工智能
用户7106207733402 小时前
Codex-端口配置错误排查案例(stream disconnected before completion)
人工智能