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")
相关推荐
Elastic 中国社区官方博客11 分钟前
Elastic AI agent builder 介绍(三)
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
小喵要摸鱼24 分钟前
【深度学习】超参数调整(Hyperparameter Tuning)
深度学习·超参数调整
这张生成的图像能检测吗41 分钟前
(论文速读)YOLA:学习照明不变特征的低光目标检测
图像处理·人工智能·目标检测·计算机视觉·低照度
ZPC82101 小时前
opencv 获取图像中物体的坐标值
人工智能·python·算法·机器人
亚里随笔1 小时前
AsyPPO_ 轻量级mini-critics如何提升大语言模型推理能力
人工智能·语言模型·自然语言处理·llm·agentic
coding_ksy1 小时前
基于启发式的多模态风险分布越狱攻击,针对多模态大型语言模型(ICCV 2025) - 论文阅读和解析
人工智能·语言模型
Louisejrkf1 小时前
U-net系列算法
深度学习
算家计算2 小时前
5年后手机和APP将成历史?马斯克最新预言背后:端云协同与AI操作系统的未来架构
人工智能·云计算·资讯
多恩Stone2 小时前
【3DV 进阶-5】3D生成中 Inductive Bias (归纳偏置)的技术路线图
人工智能·python·算法·3d·aigc