Efficient-AI-Backbones icon indicating copy to clipboard operation
Efficient-AI-Backbones copied to clipboard

TypeError: __init__() got an unexpected keyword argument 'bn_tf'

Open ModeSky opened this issue 2 years ago • 12 comments

Hello, I want to ask what caused the following error when running the train.py file? thank you “ TypeError: init() got an unexpected keyword argument 'bn_tf' ”

ModeSky avatar Sep 08 '22 07:09 ModeSky

Could you show more log information?

iamhankai avatar Sep 08 '22 08:09 iamhankai

ImportError: cannot import name 'container_abcs' from 'torch._six' Now the error has changed

ModeSky avatar Sep 08 '22 08:09 ModeSky

For the previous error, I just lowered the version of timm to 0.3.2, but torch is 1.10.0. Is this the reason for this error?

ModeSky avatar Sep 08 '22 08:09 ModeSky

Training with a single process on 1 GPUs. Traceback (most recent call last): File "D:/Study/CV/important_code/vig_pytorch/train.py", line 808, in main() File "D:/Study/CV/important_code/vig_pytorch/train.py", line 341, in main checkpoint_path=args.initial_checkpoint) File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\factory.py", line 71, in create_model model = create_fn(pretrained=pretrained, pretrained_cfg=pretrained_cfg, **kwargs) File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\resnet.py", line 847, in resnet101 return _create_resnet('resnet101', pretrained, **model_args) File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\resnet.py", line 736, in _create_resnet return build_model_with_cfg(ResNet, variant, pretrained, **kwargs) File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\helpers.py", line 531, in build_model_with_cfg model = model_cls(**kwargs) if model_cfg is None else model_cls(cfg=model_cfg, **kwargs) TypeError: init() got an unexpected keyword argument 'bn_tf'

ModeSky avatar Sep 08 '22 08:09 ModeSky

Training with a single process on 1 GPUs. Traceback (most recent call last):   File "D:/Study/CV/important_code/vig_pytorch/train.py", line 808, in <module>     main()   File "D:/Study/CV/important_code/vig_pytorch/train.py", line 341, in main     checkpoint_path=args.initial_checkpoint)   File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\factory.py", line 71, in create_model     model = create_fn(pretrained=pretrained, pretrained_cfg=pretrained_cfg, **kwargs)   File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\resnet.py", line 847, in resnet101     return _create_resnet('resnet101', pretrained, **model_args)   File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\resnet.py", line 736, in _create_resnet     return build_model_with_cfg(ResNet, variant, pretrained, **kwargs)   File "C:\Users\jcy14\Anaconda3\lib\site-packages\timm\models\helpers.py", line 531, in build_model_with_cfg     model = model_cls(**kwargs) if model_cfg is None else model_cls(cfg=model_cfg, **kwargs) TypeError: init() got an unexpected keyword argument 'bn_tf'

------------------ 原始邮件 ------------------ 发件人: "huawei-noah/Efficient-AI-Backbones" @.>; 发送时间: 2022年9月8日(星期四) 下午4:16 @.>; @.@.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

Could you show more log information?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 08 '22 08:09 ModeSky

It seems you run ResNet101.

Please run as python -m torch.distributed.launch --nproc_per_node=1 train.py /path/to/imagenet/ --model pvig_s_224_gelu --sched cosine --epochs 300 --opt adamw -j 8 --warmup-lr 1e-6 --mixup .8 --cutmix 1.0 --model-ema --model-ema-decay 0.99996 --aa rand-m9-mstd0.5-inc1 --color-jitter 0.4 --warmup-epochs 20 --opt-eps 1e-8 --repeated-aug --remode pixel --reprob 0.25 --amp --lr 2e-3 --weight-decay .05 --drop 0 --drop-path .1 -b 128 --output /path/to/save/models/

with timm 0.3.2, and torch 1.7.0.

iamhankai avatar Sep 08 '22 10:09 iamhankai

作者您好,根据您的解答,我下好预训练的ViG权重,目前代码里的train使用的是resnet model,所以我需要把预权重导入进去是吧,但是有个疑问,为什么只有train.py,没有测试的py程序?还是说train就是将主程序一起并入了,本项目没有图片可视化测试是吗?

------------------ 原始邮件 ------------------ 发件人: "Kai @.>; 发送时间: 2022年9月8日(星期四) 晚上6:44 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

It seems you run ResNet101.

Please run as python -m torch.distributed.launch --nproc_per_node=1 train.py /path/to/imagenet/ --model pvig_s_224_gelu --sched cosine --epochs 300 --opt adamw -j 8 --warmup-lr 1e-6 --mixup .8 --cutmix 1.0 --model-ema --model-ema-decay 0.99996 --aa rand-m9-mstd0.5-inc1 --color-jitter 0.4 --warmup-epochs 20 --opt-eps 1e-8 --repeated-aug --remode pixel --reprob 0.25 --amp --lr 2e-3 --weight-decay .05 --drop 0 --drop-path .1 -b 128 --output /path/to/save/models/

with timm 0.3.2, and torch 1.7.0.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 09 '22 07:09 ModeSky

您好,请仔细阅读readme,谢谢!测试程序包含在train.py里面,调用方式:

python train.py /path/to/imagenet/ --model pvig_s_224_gelu -b 256 --pretrain_path /path/to/pretrained/model/ --evaluate

iamhankai avatar Sep 11 '22 04:09 iamhankai

作者您好,我想请教一下Vig的代码使用的数据集是Imagenet,要下载后导入还是直接采用的库里的ImageNet数据集

------------------ 原始邮件 ------------------ 发件人: "huawei-noah/Efficient-AI-Backbones" @.>; 发送时间: 2022年9月8日(星期四) 晚上6:44 @.>; @.@.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

It seems you run ResNet101.

Please run as python -m torch.distributed.launch --nproc_per_node=1 train.py /path/to/imagenet/ --model pvig_s_224_gelu --sched cosine --epochs 300 --opt adamw -j 8 --warmup-lr 1e-6 --mixup .8 --cutmix 1.0 --model-ema --model-ema-decay 0.99996 --aa rand-m9-mstd0.5-inc1 --color-jitter 0.4 --warmup-epochs 20 --opt-eps 1e-8 --repeated-aug --remode pixel --reprob 0.25 --amp --lr 2e-3 --weight-decay .05 --drop 0 --drop-path .1 -b 128 --output /path/to/save/models/

with timm 0.3.2, and torch 1.7.0.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 19 '22 12:09 ModeSky

We followed the official pytorch example: move and extract the training and validation images to labeled subfolders, using the following shell script

iamhankai avatar Sep 20 '22 02:09 iamhankai

 作者您好,我想问一下去,论文里使用的数据集的目录结构是什么样的,能麻烦您发给我参考一下吗?谢谢

------------------ 原始邮件 ------------------ 发件人: "huawei-noah/Efficient-AI-Backbones" @.>; 发送时间: 2022年9月20日(星期二) 上午10:49 @.>; @.@.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

We followed the official pytorch example: move and extract the training and validation images to labeled subfolders, using the following shell script

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 20 '22 09:09 ModeSky

dir/
  train/
    ...
  val/
    n01440764/
      ILSVRC2012_val_00000293.JPEG
      ...
    ...

iamhankai avatar Sep 21 '22 02:09 iamhankai

作者您好,我将imgenet数据集进行缩减到1000类160000张,在服务器里跑程序时,直接报错,请问时数据集的问题还是代码里的参数要修改?

------------------ 原始邮件 ------------------ 发件人: "huawei-noah/Efficient-AI-Backbones" @.>; 发送时间: 2022年9月21日(星期三) 上午10:08 @.>; @.@.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

dir/ train/ ... val/ n01440764/ ILSVRC2012_val_00000293.JPEG ... ...
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 22 '22 12:09 ModeSky

作者您好,我想问一下,原论文里数据集目录里没有标签文件是吧,就是imagenet自带的ILSVRC2012_devkit_t12文件夹,还是要自己生成相关的标签txt文件?

------------------ 原始邮件 ------------------ 发件人: "huawei-noah/Efficient-AI-Backbones" @.>; 发送时间: 2022年9月21日(星期三) 上午10:08 @.>; @.@.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

dir/ train/ ... val/ n01440764/ ILSVRC2012_val_00000293.JPEG ... ...
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ModeSky avatar Sep 23 '22 01:09 ModeSky

We followed the official pytorch example: move and extract the training and validation images to labeled subfolders, using the following shell script

Please read this example first. It seems you're not familiar to ImageNet training.

iamhankai avatar Sep 23 '22 02:09 iamhankai

好的,谢谢

------------------ 原始邮件 ------------------ 发件人: "Kai @.>; 发送时间: 2022年9月20日(星期二) 上午10:49 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [huawei-noah/Efficient-AI-Backbones] TypeError: init() got an unexpected keyword argument 'bn_tf' (Issue #134)

我们跟随着官方pytorch示例:将训练和验证图像移动并提取到有标签的子文件夹,使用下面的shell脚本

— 直接回复此邮件,在GitHub上查看,或取消订阅. @.***与>.

ModeSky avatar Oct 11 '22 08:10 ModeSky