fabvio / ld-lsi

Deep learning based lane/freespace detector embedded in ROS node (built for UC3M LSI)
89 stars 18 forks source link

Confused in loading weights #8

Open sachinsharma9780 opened 4 years ago

sachinsharma9780 commented 4 years ago

loading weights

  1. model_w = torch.load('Desktop/ld-lsi/res/weights/weights_erfnet_road.pth')
  2. new_mw = {}
  3. for k,w in model_w.items():
  4. new_mw[k[7:]] = w
  5. roadnet.load_state_dict(new_mw)

    roadnet.to(device) roadnet.eval();

I am a little confused here: 1). In 1. we are loading pretrained weights of erfnet_road model, so these are the weights of the model which is mentioned in the paper (giving 76% acc on BDD100k) or these are the pretrained weights of encoder trained on ImageNet dataset? 2) so what line 3 and 4 are doing is taking each layer, omitting module word from there and taking its corresponding weights and saving them in new_mw dict and everything else remains the same then what is difference between new_mw and model_w since they both have the same weights for each layer. 3) What is the role of pretrained network (weights_erfnet_road.pth) here? What if I want to train the model from scratch i.e without using pretrained weights can I get the same results as mentioned in the paper ?

Thank You!

khizar-anjum commented 3 years ago

You are right in points 1 and 2 here. There is no difference except if you try to load model_w directly, it does not work for some reason. For 3, just train the network without the command roadnet.load_state_dict(new_mw)