pytorch-semseg icon indicating copy to clipboard operation
pytorch-semseg copied to clipboard

TypeError: string indices must be integers, not str when run test.py

Open henry678 opened this issue 5 years ago • 3 comments

Hello, When I run test.py, I get the following error:

Traceback (most recent call last):
  File "/home/ubuntu/pytorch-semseg/test.py", line 170, in <module>
    test(args)
  File "/home/ubuntu/pytorch-semseg/test.py", line 67, in test
    model = get_model(model_name, n_classes, version=args.dataset)
  File "/home/ubuntu/pytorch-semseg/ptsemseg/models/__init__.py", line 14, in get_model
    name = model_dict['arch']
TypeError: string indices must be integers, not str

How to solve the problem? Thank you for your help.

henry678 avatar Sep 19 '18 03:09 henry678

@henry678 the code change in this PR fixed this problem for me https://github.com/meetshah1995/pytorch-semseg/pull/133

helinwang avatar Sep 26 '18 22:09 helinwang

Your code did not fix anything. Where is the dictionary that we are supposed to pass in? Is it supposed to come from a file?

johnathanchiu avatar Nov 19 '18 03:11 johnathanchiu

Your code did not fix anything. Where is the dictionary that we are supposed to pass in? Is it supposed to come from a file?

@johnathanchiu @henry678 there are some changes to be made in test.py to make it run. The error here states that get_model function accepts a dict, but the input is the name of the model which is a string. Change it accordingly like in train.py or validate.py. Then you will be able to run it.

komms avatar Dec 28 '18 11:12 komms