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 分钟前
决策闭环的第三公里:从洞察到行动之间,AI能补上什么
大数据·数据库·人工智能
一次旅行5 分钟前
RLHF全链路深度解析:Reward Model数学推导+PPO完整实战,对比GRPO轻量化方案
人工智能·算法·机器学习
HIT_Weston7 分钟前
164、【Agent】【OpenCode】TuiThreadCmd(工厂设计对比)
人工智能·agent·opencode
Wang's Blog8 分钟前
AI Agent白手起家29: Few Shot 提示词工程实战
人工智能·算法
杰佛史彦明 本王是暴君12 分钟前
PyTorch KernelAgent 源码解读 ---(2)--- 总体流程
人工智能·pytorch·python
澜舟孟子开源社区23 分钟前
从流程自动化到认知智能化:LangClaw 携手澜舟智库打造业务决策型数字专家
人工智能
云端漫步198736 分钟前
HarmonyOS NEXT AI 智能生活助手:AI 代码解释
人工智能·华为·生活·harmonyos
console.log('npc')36 分钟前
OptMem 使用教程
人工智能·ai编程·记忆
世优科技虚拟人40 分钟前
数字人厂商赋能学校教育:校史馆党建科普导览AI数字人应用观察
人工智能·智慧校园·ai数字人·数字人一体机·大屏数字人
sali-tec41 分钟前
C# 基于OpenCv的视觉工作流-章100-抠图
图像处理·人工智能·opencv·计算机视觉