【bug】可图文生图模型 KolorsPipeline IndexError: list index out of range

【bug】可图文生图模型 KolorsPipeline IndexError: list index out of range

环境

shell 复制代码
linux
diffusers     0.30.0

问题详情

报错详情

python 复制代码
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

运行代码

python 复制代码
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)

相关推荐
Freak嵌入式6 分钟前
MicroPython LVGL基础知识和概念:显示与多屏管理
开发语言·python·github·php·gui·lvgl·micropython
枕布响丸辣10 分钟前
Python 操作 MySQL 数据库从入门到精通
数据库·python·mysql
The_Ticker36 分钟前
印度股票实时行情API(低成本方案)
python·websocket·算法·金融·区块链
ZC跨境爬虫42 分钟前
Scrapy工作空间搭建与目录结构解析:从初始化到基础配置全流程
前端·爬虫·python·scrapy·自动化
EAIReport1 小时前
国外网站数据批量采集技术实现路径
开发语言·python
Ulyanov1 小时前
基于ttk的现代化Python音视频播放器:UI设计与可视化技术深度解析
python·ui·音视频
Freak嵌入式1 小时前
MicroPython LVGL基础知识和概念:时序与动态效果
开发语言·python·github·php·gui·lvgl·micropython
zhangzeyuaaa2 小时前
Python 中的 Map 和 Reduce 详解
开发语言·python
Cc_Debugger2 小时前
【饿了么plus-table】开启多选时,点击下面的单选按钮,页面显示是全选的样子,bug
bug
七夜zippoe2 小时前
Java技术未来展望:GraalVM、Quarkus、Helidon等新趋势探讨
java·开发语言·python·quarkus·graaivm·helidon