awesome-semantic-segmentation-pytorch: KeyError: 'local_rank'

Hi, “python3 demo.py --model fcn32s_vgg16_voc --input-pic ./datasets/test.png” running.

Error Code:

Traceback (most recent call last):
  File "demo.py", line 58, in <module>
    demo(args)
  File "demo.py", line 44, in demo
    model = get_model(args.model, pretrained=True, root=args.save_folder).to(device)
  File "/home/sercan/awesome-semantic-segmentation-pytorch/core/models/model_zoo.py", line 90, in get_model
    net = _models[name](**kwargs)
  File "/home/sercan/awesome-semantic-segmentation-pytorch/core/models/fcn.py", line 209, in get_fcn32s_vgg16_voc
    return get_fcn32s('pascal_voc', 'vgg16', **kwargs)
  File "/home/sercan/awesome-semantic-segmentation-pytorch/core/models/fcn.py", line 164, in get_fcn32s
    device = torch.device(kwargs['local_rank'])
KeyError: 'local_rank'

Why am I getting such an error? Can you help me ?

About this issue

Most upvoted comments

I got the same error, then I modify the file like this, it works. I hope this will help you. https://github.com/xyry/awesome-semantic-segmentation-pytorch/pull/1/commits/05b7de785dd15e618ce82418619a358bf472ca01

I also got the same error, then I modify the core/models/base_models/resnetv1b.py in line 95 like this: zero_init_residual=False, norm_layer=nn.BatchNorm2d, **kwargs):

Same error in demo.py, I modified demo.py like this.

model = get_model(args.model, pretrained=True, root=args.save_folder, local_rank=device).to(device) It works for me.

I have the same issue when I was trying to evaluate the fcn model with resnet50 backbone. Weird thing is that ‘local_rank’ is not an argument for running, but when trying to load the model it just appears. Hoping to solve this issue.

Instead of kwargs['local_rank'] in eval.py or demo.py, substitute it with 0 or 1 accordingly whether its cpu or cuda. So, that specific line becomes device= torch.device(0) or device= torch.device(1). Please close this issue if this works for you. It had worked for me.

There is no problem when training. I found this issue when running eval.py .