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")
相关推荐
golang学习记5 分钟前
Anthropic 发布轻量级模型Claude Haiku 4.5:更快,更便宜,更聪明
人工智能
bin915317 分钟前
当AI开始‘映射‘用户数据:初级Python开发者的创意‘高阶函数‘如何避免被‘化简‘?—— 老码农的函数式幽默
开发语言·人工智能·python·工具·ai工具
CoovallyAIHub33 分钟前
Mamba-3震撼登场!Transformer最强挑战者再进化,已进入ICLR 2026盲审
深度学习·算法·计算机视觉
飞哥数智坊1 小时前
一文看懂 Claude Skills:让你的 AI 按规矩高效干活
人工智能·claude
JY190641061 小时前
从点云到模型,徕卡RTC360如何搞定铝单板测量?
深度学习
IT_陈寒2 小时前
5个Java 21新特性实战技巧,让你的代码性能飙升200%!
前端·人工智能·后端
dlraba8022 小时前
YOLOv3:目标检测领域的经典之作
人工智能·yolo·目标检测
科新数智2 小时前
破解商家客服困局:真人工AI回复如何成为转型核心
人工智能·#agent #智能体
szxinmai主板定制专家4 小时前
【NI测试方案】基于ARM+FPGA的整车仿真与电池标定
arm开发·人工智能·yolo·fpga开发
ygyqinghuan5 小时前
读懂目标检测
人工智能·目标检测·目标跟踪