python 3.11 运行 timm 0.6.12无法import

python3.11 安装了 timm 0.6.12 后,在import timm时报错:

复制代码
ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for field conv_cfg is not allowed: use default_factory

在hugging face官方的issue中给出了解决方案:

https://github.com/huggingface/pytorch-image-models/issues/1530

做一次文件修改即可:

打开安装路径中的timm

你的timm路径\]/models/maxxvit.py 首先在line 42添加 field,即从原本的 from dataclasses import dataclass, replace 改为 from dataclasses import dataclass, replace, field 然后修改lines 232、233,从原本的 conv_cfg: MaxxVitConvCfg = MaxxVitConvCfg() transformer_cfg: MaxxVitTransformerCfg = MaxxVitTransformerCfg() 改为 conv_cfg: MaxxVitConvCfg = field(default_factory=MaxxVitConvCfg) transformer_cfg: MaxxVitTransformerCfg = field(default_factory=MaxxVitTransformerCfg) 即可

相关推荐
love530love18 天前
stable diffusion webui 更改为python3.11版本运行Windows11
stable diffusion·python3.11
ftpeak1 个月前
在 Linux下使用 Python 3.11 和 FastAPI 搭建带免费证书的 HTTPS 服务器
https·fastapi·python3.11
人才程序员3 个月前
【PySide6快速入门】QFileDialog 文件选择对话框
c语言·c++·qt·microsoft·pyside6·python3.11
人才程序员3 个月前
【PySide6快速入门】ui文件的使用
c语言·开发语言·前端·qt·ui·python3.11·界面
hshpy3 个月前
start using Python 3.11 after installation
windows·python·python3.11
卜及中3 个月前
【Pytest】基础到高级功能的理解使用
开发语言·python·学习·pytest·python3.11
卜及中3 个月前
【Sanic 框架 / 1】深入学习:从入门到进阶
python·学习·web3·python3.11
mixboot3 个月前
macOS 安装 python3.11
macos·python3.11
vvw&4 个月前
如何在 Ubuntu 22.04 上安装 JupyterLab 环境教程
linux·运维·服务器·ubuntu·jupyter·开源·python3.11
Guofu_Liao5 个月前
大语言模型---Llama不同系列的权重参数文件提取;Llama-7B权重文件提取;Llama-8B权重文件提取;主要代码功能解析
人工智能·语言模型·自然语言处理·chatgpt·aigc·llama·python3.11