Description
import timm
Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/init.py", line 2, in
from .models import create_model, list_models, is_model, list_modules, model _entrypoint,
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/models/init.py ", line 28, in
from .maxxvit import *
File "/home/ubuntu/.local/lib/python3.11/site-packages/timm/models/maxxvit.py" , line 216, in
@DataClass
^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 1221, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 1211, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 959, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/dataclasses.py", line 816, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for fie ld conv_cfg is not allowed: use default_factory
Activity
rwightman commentedon Nov 4, 2022
@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?
futurisold commentedon Feb 1, 2023
The fix should be relatively straightforward:
SPOOKEXE commentedon Oct 28, 2023
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"
glacier434 commentedon Oct 29, 2023
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
Add field to the end. So it will look like this.
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!
(make a copy of that file first, jic)
plaidpants commentedon Dec 25, 2023
Thanks, works for me now also.
Eugeniusz-Gienek commentedon Dec 31, 2023
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.
So, summary of how to apply this change (step by step) - on the example of Kohya.
Specifically for those who are unfamiliar with Python :)
xingyouxin commentedon Apr 30, 2024
I have solved my problem with this help! Thank you very much! Remember to add [field] and then release the codes respectively 4 times!
TaciteOFF commentedon Dec 16, 2024
This didn't work for me but downgrading timm from 0.6.12 to 0.6.7 worked.