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")
相关推荐
好奇龙猫1 小时前
【人工智能学习-AI入试相关题目练习-第七次】
人工智能·学习
Mao.O4 小时前
开源项目“AI思维圆桌”的介绍和对于当前AI编程的思考
人工智能
jake don4 小时前
AI 深度学习路线
人工智能·深度学习
信创天地4 小时前
信创场景软件兼容性测试实战:适配国产软硬件生态,破解运行故障难题
人工智能·开源·dubbo·运维开发·risc-v
幻云20105 小时前
Python深度学习:从筑基到登仙
前端·javascript·vue.js·人工智能·python
bst@微胖子5 小时前
LlamaIndex之核心概念及部署以及入门案例
pytorch·深度学习·机器学习
无风听海5 小时前
CBOW 模型中的输出层
人工智能·机器学习
汇智信科5 小时前
智慧矿山和工业大数据解决方案“智能设备管理系统”
大数据·人工智能·工业大数据·智能矿山·汇智信科·智能设备管理系统
静听松涛1335 小时前
跨语言低资源场景下的零样本迁移
人工智能
SEO_juper5 小时前
AI+SEO全景决策指南:10大高价值方法、核心挑战与成本效益分析
人工智能·搜索引擎·seo·数字营销