Tramac / awesome-semantic-segmentation-pytorch

Semantic Segmentation on PyTorch (include FCN, PSPNet, Deeplabv3, Deeplabv3+, DANet, DenseASPP, BiSeNet, EncNet, DUNet, ICNet, ENet, OCNet, CCNet, PSANet, CGNet, ESPNet, LEDNet, DFANet)
Apache License 2.0
2.83k stars 581 forks source link

model file path issue. Getting error - ValueError: Model file is not found. Downloading or training. Please help! #211

Open bbbts opened 3 months ago

bbbts commented 3 months ago

after training. I saved my model file in a folder called 'MODEL FILE' (I edited it in the train.py file) and the training was done successfully. In how many places and/or files do I have to make changes so that I can run eval.py file correctly(so that it recognizes my 'MODEL FILE' folder correctly)? Here is how the folder structure looks like -

image

Please help. Thanks!

mahammadirfan commented 2 weeks ago

I tackled this problem by first changing the default parameter --save-folder (second image below) to wherever my model is being downloaded (first image below). After that, I change the name of downloaded file to what this repo wants the filename to be.

image

image

For example, if you want to use fcn32s_vgg16_voc model, check the name of corresponding function name in the dictionary within file core/models/model_zoo.py. For fcn32s_vgg16_voc, the function name is get_fcn32s_vgg16_voc,.

Now this function doesn't do anything but calls another function get_fcn32s, that actually downloads the model using torch.load() and get_model_file() functions, the latter of which is PyTorch's internal function and latter can be found at core/models/model_store.py.

See line number 168, notice how I print the the model's name using the information given in the next line. image

But even after loading the model, the state dictionary's parameters didn't match the pretrained downloaded file's parameters (shown below). I think it's only the difference in naming convention that's causing the issue.

image

@Tramac Let us know if you'll be going to update the codebase to accommodate updated pretrained files from PyTorch's official server.

Thanks