ooooverflow / BiSeNet

BiSeNet based on pytorch
395 stars 76 forks source link

AttributeError: 'BiSeNet' object has no attribute 'module' #1

Closed Eileen2014 closed 5 years ago

Eileen2014 commented 6 years ago

load model from ./checkpoints/epoch_295.pth ... Traceback (most recent call last): File "c:\Users\Administrator\Desktop\BiSeNet-master\BiSeNet-master\demo.py", line 80, in main(params) File "c:\Users\Administrator\Desktop\BiSeNet-master\BiSeNet-master\demo.py", line 60, in main model.module.load_state_dict(torch.load(args.checkpoint_path)) File "C:\Program Files\Python\lib\site-packages\torch\nn\modules\module.py", line 518, in getattr type(self).name, name)) AttributeError: 'BiSeNet' object has no attribute 'module' PS C:\Users\Administrator\Desktop\BiSeNet-master\BiSeNet-master> Where do I put the dataset ?

hubutui commented 5 years ago

Is your gpu available? check https://github.com/ooooverflow/BiSeNet/blob/master/eval.py#L70, after

model = torch.nn.DataParallel(model).cuda()

model need to load state dict by:

model.module.load_state_dict(torch.load(args.checkpoint_path))

Not:

model.load_state_dict(torch.load(args.checkpoint_path))

Maybe a better solution is load state dict before line:

model = torch.nn.DataParallel(model).cuda()
EchoAmor commented 5 years ago

Have anyone solved this problem???

zz10001 commented 5 years ago

Have anyone solved this problem???

have you sovled it?

zz10001 commented 5 years ago

have you sovled it?

maybe you just delete .module if you just you use one gpu.

EchoAmor commented 5 years ago

no I didn't . Thanks I'll try @zz10001

Leeyed commented 3 years ago

if your pc have more than one gpu. Before: model.to(device) You should add: model = nn.DataParallel(model)

BEFORE: device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model.to(device) AFTER: device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") if torch.cuda.device_count() > 1: \Space model = nn.DataParallel(model) model.to(device)