Ai
42 Star 397 Fork 242

Ascend/MindSpeed-MM
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
infer_sd3_img2img.py 811 Bytes
一键复制 编辑 原始数据 按行查看 历史
J石页 提交于 2024-12-04 16:11 +08:00 . !423【特性】新增SD3.5支持
# Copyright 2024 Huawei Technologies Co., Ltd
# Copyright 2024 Stability AI, The HuggingFace Team and The InstantX Team. All rights reserved.
# Copyright 2024 Stability AI and The HuggingFace Team
import torch
from diffusers import StableDiffusion3Img2ImgPipeline
from diffusers.utils import load_image
DTYPE = torch.float16
MODEL_PATH = (
"stabilityai/stable-diffusion-3-medium-diffusers" # 模型权重路径 或 微调结果路径
)
DEVICE = "npu"
pipe = StableDiffusion3Img2ImgPipeline.from_pretrained(
MODEL_PATH,
torch_dtype=DTYPE,
local_files_only=True,
).to(DEVICE)
init_image = load_image("cat.png")
prompt = "cat wizard, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney, 8k"
image = pipe(prompt, image=init_image).images[0]
image.save("cat_wizard.png")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ascend/MindSpeed-MM.git
git@gitee.com:ascend/MindSpeed-MM.git
ascend
MindSpeed-MM
MindSpeed-MM
master

搜索帮助