ImageCaptioning.pytorch
ImageCaptioning.pytorch copied to clipboard
Cpu issue
I changed the eval.py to run it on cpu but I was encountered to some error. Can you provide the cpu version of it? Thanks in advance
I don't have that. What error did you meet?
The error is: module object has no attribute cuda_getdevice That it is relate to this line of code: model.load_state_dict(torch.load(opt.model))
model.load_state_dict(torch.load(opt.model, map_location=lambda storage, loc: storage))
try this
I tried this but the error was not solved.
I can load it properly on a no-gpu machine in this way.
I was encountered the same error. Can you provide the change in code in detail?
Loading the model succeeds, but running any eval code fails because there's .cuda()
calls all over the place. You'll have to remove all of them. I made a quick fork to demonstrate: https://github.com/kcarnold/ImageCaptioning.pytorch
The "right" solution is to use type_as
within the models, but that's more work.
@kcarnold I run your code it gives this error. Do you have any idea?
Traceback (most recent call last): File "eval.py", line 122, in
vars(opt)) File "/ImageCaptioning.pytorch/eval_utils.py", line 105, in eval_split sents = utils.decode_sequence(loader.get_vocab(), seq) File "/ImageCaptioning.pytorch/misc/utils.py", line 27, in decode_sequence txt = txt + ix_to_word[str(ix)] KeyError: 'tensor(7961)'
This is because you are using pytorch 0.4.
@kcarnold I run your code it gives this error. Do you have any idea?
Traceback (most recent call last): File "eval.py", line 122, in vars(opt)) File "/ImageCaptioning.pytorch/eval_utils.py", line 105, in eval_split sents = utils.decode_sequence(loader.get_vocab(), seq) File "/ImageCaptioning.pytorch/misc/utils.py", line 27, in decode_sequence txt = txt + ix_to_word[str(ix)] KeyError: 'tensor(7961)'
just change this line: txt = txt + ix_to_word[str(ix)] to: txt = txt + ix_to_word[str(int(ix))]