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")
相关推荐
小程故事多_804 分钟前
从零吃透PyTorch,最易懂的入门全指南
人工智能·pytorch·python
AI科技星5 分钟前
统一场论中电场的几何起源:基于立体角变化率的第一性原理推导与验证
服务器·人工智能·线性代数·算法·矩阵·生活
晓晓不觉早7 分钟前
2026 AI 垂直领域展望:从通用到专精,场景深耕成破局关键
人工智能
lifetime‵(+﹏+)′8 分钟前
5060显卡Windows配置Anaconda中的CUDA及Pytorch
人工智能·pytorch·windows
老鱼说AI8 分钟前
万字长文警告!一次性搞定GAN(生成对抗网络):从浅入深原理级精析 + PyTorch代码逐行讲解实现
人工智能·深度学习·神经网络·生成对抗网络·计算机视觉·ai作画·超分辨率重建
START_GAME10 分钟前
深度学习环境配置:PyTorch、CUDA和Python版本选择
人工智能·pytorch·深度学习
盼小辉丶10 分钟前
PyTorch生成式人工智能(30)——扩散模型(Diffusion Model)
pytorch·深度学习·生成模型·扩散模型
Chlittle_rabbit12 分钟前
50系显卡在Ubuntu22.04环境下安装nvidia驱动+CUDA+cuDNN,anaconda下配置pytorch环境一站式解决方案(2025年7月版本)已完结!!!
linux·人工智能·pytorch·深度学习·ubuntu
大模型真好玩28 分钟前
LangGraph智能体开发设计模式(三)——LangGraph多智能体设计模式:主管架构与分层架构
人工智能·langchain·agent
皇族崛起1 小时前
【视觉多模态】- 3D建模尝试 I (广场3D建模,失败)
数据库·人工智能·3d·性能优化