赞
踩
linux
diffusers 0.30.0
报错详情
from diffusers import KolorsPipeline
Traceback (most recent call last):
File "Kolors/demo.py", line 6, in <module>
pipe = KolorsPipeline.from_pretrained(
File ".conda/envs/xxx/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File ".conda/envs/xxx/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 732, in from_pretrained
variant_exists = is_folder and any(
File ".conda/envs/xxx/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 733, in <genexpr>
p.split(".")[1].startswith(variant) for p in os.listdir(folder_path)
IndexError: list index out of range
运行代码
import torch
from diffusers import KolorsPipeline
# 模型地址,可以改为本地离线地址
root_dir = "Kwai-Kolors/Kolors-diffusers"
pipe = KolorsPipeline.from_pretrained(
root_dir,
torch_dtype=torch.float16,
variant="fp16"
).to("cuda")
prompt = '一张瓢虫的照片,微距,变焦,高质量,电影,拿着一个牌子,写着"可图"'
image = pipe(
prompt=prompt,
negative_prompt="",
guidance_scale=5.0,
num_inference_steps=50,
generator=torch.Generator(pipe.device).manual_seed(66),
).images[0]
# image.show()
image.save("image.jpg")
错误说明
这个错误是由于模型中text_encoder
文件夹下存在 __pycache__
文件夹导致模型加载错误。
解决方法是删除 text_encoder
文件夹下的 __pycache__
文件夹。
我的模型是在可图 · 模型库 (modelscope.cn)下载的,官方没有去掉
__pycache__
。如果是在Kwai-Kolors/Kolors-diffusers at main (huggingface.co) 下载,官方去掉了
__pycache__
文件夹,因此不会出现这个错误
Support for Kolors · Issue #8801 · huggingface/diffusers (github.com)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。