代码拉取完成,页面将自动刷新
# 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")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。