Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any hints about using the pre-trained pkl file? #10

Open
adayoegi opened this issue Mar 10, 2017 · 6 comments
Open

Any hints about using the pre-trained pkl file? #10

adayoegi opened this issue Mar 10, 2017 · 6 comments

Comments

@adayoegi
Copy link

Hi, I am a newbie to ML and just followed the readme to download the FCN model, without any idea using it.
My goal is to use the pre-trained model and see how it works, because my GPU is around 6GB which seems not enough for training.
I googled the pkl file and it seems to be something working with python pickle model, so I:

python
ActivePython 2.7.10.12 (ActiveState Software Inc.) based on
Python 2.7.10 (default, Aug 21 2015, 12:07:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import pickle
loaded_model = pickle.load(open('fcn-8s-pascalcontext_W_and_b.pkl', 'rb'))

and get the dictionary "loaded model", with a bunch of numbers, while the keys are:

loaded_model.keys()
['conv4_3_W', 'conv5_1_b', 'conv1_2_b', 'upsample_W', 'conv5_2_b', 'conv1_1_W', 'score-pool3_W', 'conv5_2_W', 'conv5_3_W', 'conv1_1_b', 'conv4_3_b', 'conv5_3_b', 'conv5_1_W', 'conv1_2_W', 'conv3_2_W', 'conv4_2_b', 'conv4_1_b', 'upscore2_W', 'conv3_3_W', 'conv2_1_b', 'conv3_1_b', 'conv2_2_W', 'fc6_b', 'score-pool4_W', 'fc7_b', 'score59_W', 'conv2_2_b', 'fc6_W', 'upsample-fused-16_W', 'score59_b', 'fc7_W', 'conv4_1_W', 'conv3_2_b', 'conv4_2_W', 'score-pool4_b', 'conv3_3_b', 'conv3_1_W', 'conv2_1_W', 'score-pool3_b']

Then stuck here, not knowing what to do next.
Could anyone please help telling how to use the pre-trained model? Any hints would be appreciative.

@ColdCodeCool
Copy link

Yes, the API of serializer.load_hdf5(args.pretrainedmodel, model) seems did not work, and even if I changed the extension of file pkl to h5 or hdf5.

@ColdCodeCool
Copy link

@shiba24 Could you please redesign the part of loading pre-trained model?

@shiba24
Copy link
Owner

shiba24 commented Jul 5, 2017

Thank you, @ColdCodeCool, I've noticed the version of chainer has changed a lot since I wrote this code. Will check it soon!

@ColdCodeCool
Copy link

@shiba24 Great! Hope to see it soon. Thank you!

@ColdCodeCool
Copy link

@shiba24 After I digged deeper into the code, I recognized that it seems the VGG model is double loaded. Since the line "model = HumanParts(n_class = 15)" has loaded the pkl file, there is no need to load the model again the next few lines.

But I got another issue that how to visulize the mask obtained by visualize.py? Thank you!

@vsegura93
Copy link

@ColdCodeCool To visualize the mask obtained by visualize.py, you can load the file with extension .npy, and then use matplot functions to save image into png format.

import matplotlib.pyplot as plt
img_array = np.load(resultdir + bname + '.npy')
plt.imsave(resultdir + bname + '.png', img_array)

Proabably is not the best way to retrieve and visualize mask. Maybe exists other ways more directly using only one line, but this two lines works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants