-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Python 3.11 Error >>> import timm ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for field conv_cfg is not allowed: use default_factory #1530
Comments
@makao007 will look at this, haven't tried w/ python 3.11 yet as there wasn't a torchvision build available, is there a 3.11 torchvision? |
The fix should be relatively straightforward: @dataclass
class MaxxVitCfg:
embed_dim: Tuple[int, ...] = (96, 192, 384, 768)
depths: Tuple[int, ...] = (2, 3, 5, 2)
block_type: Tuple[Union[str, Tuple[str, ...]], ...] = ('C', 'C', 'T', 'T')
stem_width: Union[int, Tuple[int, int]] = 64
stem_bias: bool = True
conv_cfg: MaxxVitConvCfg = field(default_factory=MaxxVitConvCfg) # <--- we need field here
transformer_cfg: MaxxVitTransformerCfg = field(default_factory=MaxxVitTransformerCfg) # <--- and here
weight_init: str = 'vit_eff' |
Can confirm the fix does indeed work, also include 'field' in the "from dataclass import ..." statement. The script you need to place this in is located at "kohya_ss-22.1.0\venv\Lib\site-packages\timm\models\maxxvit.py" |
For anyone who doesn't know an ounce or a pound of python (like me), this means that in addition to the code at the top that needs to be changed as stated, also change this line (use find to get to it) from dataclasses import dataclass, replace from dataclasses import dataclass, replace, field Don't give up. I struggled with how to interpret this and other advice all morning and finally got it to work thanks to the straightforward answers above. I finally got captions to work! yay! |
Thanks, works for me now also. |
Perfect, works for me! For those who will find this later I would like to point out that conv_cfg and transformer_cfg don't only need the change of inner arguments - the whole rows look a bit different. Besides, as I am using python 3.11 the path is a bit different.
|
I have solved my problem with this help! Thank you very much! Remember to add [field] and then release the codes respectively 4 times! |
This didn't work for me but downgrading timm from 0.6.12 to 0.6.7 worked. |
The text was updated successfully, but these errors were encountered: