val-iisc / sketch-parse

Code, demos and data for SketchParse (a neural network for sketch segmentation). Paper:

Home Page:https://arxiv.org/abs/1709.01295

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'unexpected key "pose_r0.PoseC1.0.weight" in state_dict'

codaibk opened this issue · comments

Hi, I tried to run "Retrieval-demo.ipynb" in 'retrieval-src" folder to get segment for sketch. But i dunno why it got this error "unexpected key "pose_r0.PoseC1.0.weight" in state_dict" when loading model using this command: "model.load_state_dict(saved_state_dict)".
Im sure that i downloaded "model_r5_p50x_D1_17000.pth" file and it is in correct folder.
Do you have any suggestion?
Thanks

Just for reference, what version of pytorch are you using?

Okay, so I see the error. I think you may have changed some of your file paths locally, so I'll tell you what to fix, so you don't have to deal with merge conflicts while pulling. I'll also push a general fix later today.

In "Retrieval-demo.ipynb":

  • change resnet_dilated_frozen_r5_D to import resnet_dilated_frozen_r5_D_pose
  • change model = getattr(resnet_dilated_frozen_r5_D, "Res_Deeplab")() to model = getattr(resnet_dilated_frozen_r5_D_pose, "Res_Deeplab")()

I have tested that this works on pytorch 0.2.0. It should also work on newer versions.
Thanks, for reaching out and let us know if you have any other questions!

Hi. Thanks for reply. My pytorch's version is 0.3. I followed your changing and it works ^^.
Btw, How can i generate the mode file .pth (example : model_r5_p50x_D1_17000.pth) which i used in this case?. I downloaded it from your link (http://val.serc.iisc.ernet.in/star_snapshots/) so far. is it not from running "train_r5.py"? because the result is not good if i tried with model from train_r5.py compared to the one which i downloaded from your link.
Thanks

When you say the result is not good, do you mean the result is not good visually?
If so, are you using train_r5.py with your own data or the data we provided?

Hi,
I mean the segmented sketch is not good. I used your provided data.
example this is sketch input:
image
This is segmented sketch output with model_r5_p50x_D1_17000.pth (downloaded from provided link)
image
And this is segmented sketch output with model r5_20.0k_bs1_lr5.00e-04_20000.pth (generated from train_r5.py
image
I'm wondering how you can generated model_r5_p50x_D1_17000.pth?
Thanks

Hi, sorry but what do you mean? @ravika

Hi, can you show me the output you get when you evaluate your saved models using eval_r5.py ?
Thanks.

Hi,
This is visualize result when evaluate the saved models using eval_r5.py
image
image
And this is final output: pytorch 20 0.224241463733 per class [0.22802222606653344, 0.21482738193826117, 0.2407933974958083, 0.25324184749507345, 0.2918753221646367, 0.22712269633171353, 0.2275538259454787, 0.199957415011093, 0.2084129525678055, 0.19703502654489727, 0.18060113308456505]
btw, could you tell me how to generate the model file model_r5_p50x_D1_17000.pth?
Thanks,

To train model_r5_p50x_D1_17000.pth, follow these steps -

  • Download the contents of this folder. Deeplab v2 authors released a pretrained version of their net on MSCOCO. We converted it to a pytorch .pth file and use it to fine train our model. The downloaded folder contains the file MS_DeepLab_resnet_pretained_VOC.pth which corresponds to this .pth file. Please keep this .pth file in the same folder as the train script. The folder also contains train_sketches.zip and train_sketch_GT.zip which contains the augmented data (sketches and the corresponding ground truth respectively) used to train our model.

  • After extracting the 2 zip files, run

python train_r5.py --segnetLoss --lambda1 1.0 --GTpath <train gt images path here> --IMpath <train images path here> 

where,

<train gt images path here> is unzipped location of train_sketch_GT.zip

<train images path here> is unzipped location of train_sketches.zip

After training, run eval_r5.py to evaluate all the 20 saved models. Pick the one which has the best average IOU.

Did you follow these steps when you trained the above model?

Hi, I followed above steps which you mentioned. But i didn't pick the one which has the best average IOU. so far i just used the model with iter=20000. I will check the others mode then.

There seems to be some other problem, there is generally not this much variation between the models. The average IOU of iter=20000 should be very close to the one reported in the paper. Let me know if you problem persists - I will train the model to check myself.

Hi. The result of the model with best average IOU is same as iter = 20000 too. The result is not good. I am sure that i used MS_DeepLab_resnet_pretained_VOC.ph to fine tune the model.
Could you check your model again?
Thanks

I trained the model using the exact steps I mentioned above. I am able to get the performance reported in the paper(~63.17 mean IOU). Are you sure you have not modified any part of the repository's files? I would recommend that you clone a fresh copy of the repository and run experiments again.

I got best performance after 19,000 iterations. I have pasted it below -
pytorch 19 0.644417793578 per class [0.68499774429809923, 0.69250671676936393, 0.70335974561292192, 0.70946089483124919, 0.71450341102413151, 0.66840944537585745, 0.66589500526861778, 0.62695623376750753, 0.54590353230127031, 0.57492646690975235, 0.51647518366701561]

Hi, I tried to train model again and the result is ok now. Sorry for this inconvenient.
Thank you so much for replying ^_^