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")
相关推荐
AIBox3652 分钟前
ChatGPT 中文版镜像官网,GPT5.2使用教程(2025年 12 月更新)
人工智能
测试人社区-千羽7 分钟前
生物识别系统的测试安全性与漏洞防护实践
运维·人工智能·opencv·安全·数据挖掘·自动化·边缘计算
2501_924794909 分钟前
企业AI转型为何难?——从“不敢用”到“用得稳”的路径重构
大数据·人工智能·重构
Tezign_space21 分钟前
小红书内容运营工具怎么选?专业视角拆解优质工具核心标准
大数据·人工智能·内容运营
老马啸西风23 分钟前
成熟企业级技术平台 MVE-010-跳板机 / 堡垒机(Jump Server / Bastion Host)
人工智能·深度学习·算法·职场和发展
康实训23 分钟前
养老实训室建设标准指南
大数据·人工智能·实训室·养老实训室·实训室建设
袖手蹲24 分钟前
Arduino UNO Q 烘托圣诞节气氛
人工智能·单片机·嵌入式硬件
wjykp31 分钟前
part 3神经网络的学习
人工智能·神经网络·学习
core51239 分钟前
【硬核测评】Gemini 3 编程能力全面进化:不仅仅是 Copilot,更是你的 AI 架构师
人工智能·编程·copilot
Cathyqiii40 分钟前
Diff-MTS: Temporal-Augmented ConditionalDiffusion-Based AIGC
深度学习·aigc