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")
相关推荐
2601_9594779115 小时前
Vatee:数字化能力升级的全面观察
大数据·人工智能
@蔓蔓喜欢你15 小时前
Web Components:构建可复用组件的未来
人工智能·ai
JGHAI15 小时前
GEO优化:AI搜索时代的底层逻辑重构与中小企业实践路径
人工智能
庚昀◟15 小时前
ClaudeCode安装教程,基础使用、进阶推荐
人工智能·python·ai
Deep-w15 小时前
【目标检测系统网页版】基于YOLOv8的淡水鱼检测系统
人工智能·yolo·目标检测
2501_9311624315 小时前
产业观察:AI民用化落地提速,优秘智能联合产业机构构建轻量化技术赋能体系
人工智能·ai技术·技术落地
赴山海bi15 小时前
DeepBI赋能:家居类亚马逊Listing优化全攻略
大数据·人工智能
qq_3660327815 小时前
Claude API中转怎么选?简易api下的国内接入与兼容 OpenAI 接口实践
大数据·运维·人工智能
AI医影跨模态组学15 小时前
eClinMed 遵义医科大学附属医院:肺癌术后肺部并发症可解释机器学习预测模型的开发与验证:一项机器学习研究
人工智能·深度学习·机器学习·论文·医学影像·影像组学
moonsims15 小时前
分布式具身智能平台(Distributed Embodied Intelligence Platform):UAV&UGV空地协同自治系统架构(GNSS拒止)
人工智能