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

get_model line in test.py

Open david-bernstein opened this issue 5 years ago • 5 comments

I have a question about line 67 in test.py:

model = get_model(model_name, n_classes, version=args.dataset)

model_name is a string but the first argument in get_model is a dict so the code raises an exception here.

Am I missing something?

david-bernstein avatar Oct 10 '18 19:10 david-bernstein

https://github.com/meetshah1995/pytorch-semseg/blob/81997cd5af36759773a67b11cf148d3876b13a69/ptsemseg/models/init.py#L14 this line gets the model name from dict, and use _get_model_instance get an instance of the arch you want to use, what's your error?

3bobo avatar Oct 17 '18 10:10 3bobo

Thanks for your response. The problem is that get_model is being passed a string, not a dict, as the first argument in line 67 of test.py.

david-bernstein avatar Oct 17 '18 17:10 david-bernstein

oh, I get it, maybe you could add if ... else in get_model function to solve this error,such as;

if isinstance(model_dict,str):
        model = _get_model_instance(model_dict)
else:
        name = model_dict['arch']
        model = _get_model_instance(name)

3bobo avatar Oct 18 '18 00:10 3bobo

if isinstance(model_dict,str): model = _get_model_instance(model_dict) else: name = model_dict['arch'] model = _get_model_instance(name)

This wont help because later we use it again as a dictionary

serge-m avatar Nov 23 '18 10:11 serge-m

#131 check this issue. It has been answered here @serge-m @3bobo @david-bernstein

komms avatar Dec 28 '18 12:12 komms