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")
相关推荐
Modeler·X7 小时前
关系型与非关系型数据库终极对决
数据库·人工智能
颜淡慕潇7 小时前
动态代理赋能:高效爬取沃尔玛海量商品信息与AI分析实战
人工智能·后端
LOnghas12117 小时前
长须鲸目标检测_YOLO13-C3k2-OREPA改进方案实战
人工智能·目标检测·计算机视觉
Hcoco_me8 小时前
大模型面试题75:讲解一下GRPO的数据回放
人工智能·深度学习·算法·机器学习·vllm
赫尔·普莱蒂科萨·帕塔8 小时前
“共享”机器人
人工智能·机器人·agi
duyinbi75178 小时前
改进YOLO13模型:C3k2与PPA优化在油田工人安全装备检测与行为识别中的应用
人工智能·安全·目标跟踪
Duang007_8 小时前
【LeetCodeHot100 超详细Agent启发版本】两数之和 (Two Sum)
java·人工智能·python
Ydwlcloud8 小时前
AWS 2026折扣活动深度解析:寻找最大优惠的智慧路径
大数据·服务器·人工智能·云计算·aws
NingboWill8 小时前
AI日报 - 2026年01月14日
人工智能
QYR_118 小时前
聚偏二氟乙烯(PVDF)行业市场深度调研与投资前景预测报告2026版
大数据·人工智能