lxztju / pytorch_classification

利用pytorch实现图像分类的一个完整的代码,训练,预测,TTA,模型融合,模型部署,cnn提取特征,svm或者随机森林等进行分类,模型蒸馏,一个完整的代码
MIT License
1.38k stars 338 forks source link

TypeError: __init__() got an unexpected keyword argument 'weights' #51

Closed gpf1991 closed 1 year ago

gpf1991 commented 1 year ago

Traceback (most recent call last): File "./tools/train_val.py", line 176, in train(rank, local_rank, device, args) File "./tools/train_val.py", line 67, in train model = ClsModel(args.model_name, args.num_classes, args.is_pretrained) File "/root/gpf/pytorch_classification/cls_models/model.py", line 31, in init self.base_model = getattr(torchvision.models, self.model_name)(weights=ModelWeights[self.model_name]) File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 277, in resnet18 kwargs) File "/root/miniconda3/envs/pytorch_clas/lib/python3.7/site-packages/torchvision/models/resnet.py", line 260, in _resnet model = ResNet(block, layers, kwargs) TypeError: init() got an unexpected keyword argument 'weights'


使用的包版本: pytorch==1.8.1+cu101 torchvision==0.9.1+cu101

为什么会报上面的错误?

gpf1991 commented 1 year ago

已解决

wuhaowuhao commented 1 year ago

请问这个报错是怎么解决的?

Grimm-L commented 1 year ago

请问咋解决的