正鑫
正鑫
## First question I use ``` model = swinT(nclass=2, pretrained=False, aux=True, head="mlphead") model = nn.SyncBatchNorm.convert_sync_batchnorm(model) ``` to load model ,but i get ``` model.load_state_dict(checkpoint) File "/home/Zhenxin.Wang/anaconda3/envs/effitrans/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1407, in load_state_dict...
I find the errors and fix it, now it can predict single image, but still need GPU, i try to replace cuda related with cpu, but the precision has dropped...
其他代码不变,我注释掉了这两行 ``` python model = nn.SyncBatchNorm.convert_sync_batchnorm(model) model = nn.parallel.DistributedDataParallel(model, device_ids=[0, ], output_device=0) ``` 代码就在 ``` model.load_state_dict(checkpoint) ``` 这个地方报 ``` RuntimeError: Error(s) in loading state_dict for MultiEvalModule: Missing key(s) in state_dict:...
`weights`文件夹中我只保留了在我的数据集上训练好的`best_weight.pkl`,调用`GPU`测试的指标和效果都很不错,目前想在PC上预测单张照片,没有GPU,于是我写了`predict_single.py`文件,想用CPU执行预测,训练图片的HW都是384,其他的参数我都写死在`MultiEvalModule`里了,不需要通过命令行读取参数,请求大佬帮我看看我的代码哪里有问题。 ``` python # time: 2022/8/11 14:55 # author: CoffeeChicken # description : 预测单张图片 import os, warnings import torch import cv2 import torch.nn.functional as F import numpy as np import...
谢谢大佬,我按照您的建议改好了,非常感谢您这两天对我的帮助