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) 即可

相关推荐
小Tomkk10 天前
在 Trae CN IDE 中配置 Python 3.11的指南
python3.11·trae cn
玩电脑的辣条哥17 天前
一台服务器已经有个python3.11版本了,如何手动安装 Python 3.10,两个版本共存
服务器·python·python3.11
love530love1 个月前
stable diffusion webui 更改为python3.11版本运行Windows11
stable diffusion·python3.11
ftpeak2 个月前
在 Linux下使用 Python 3.11 和 FastAPI 搭建带免费证书的 HTTPS 服务器
https·fastapi·python3.11
人才程序员3 个月前
【PySide6快速入门】QFileDialog 文件选择对话框
c语言·c++·qt·microsoft·pyside6·python3.11
人才程序员4 个月前
【PySide6快速入门】ui文件的使用
c语言·开发语言·前端·qt·ui·python3.11·界面
hshpy4 个月前
start using Python 3.11 after installation
windows·python·python3.11
卜及中4 个月前
【Pytest】基础到高级功能的理解使用
开发语言·python·学习·pytest·python3.11
卜及中4 个月前
【Sanic 框架 / 1】深入学习:从入门到进阶
python·学习·web3·python3.11
mixboot4 个月前
macOS 安装 python3.11
macos·python3.11