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

Problem when loading weights #134

Closed
eiraola opened this issue Nov 18, 2019 · 14 comments
Closed

Problem when loading weights #134

eiraola opened this issue Nov 18, 2019 · 14 comments

Comments

@eiraola
Copy link

eiraola commented Nov 18, 2019

Hi, I was following this tutorial

https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html

And everrything is great, but when I try to use:

from keras_segmentation import predict

predict(
checkpoints_path="checkpoints/vgg_unet_1",
inp="dataset_path/images_prepped_test/0016E5_07965.png",
out_fname="output.png"
)

it says:

TypeError: 'module' object is not callable

The same happens with:

from keras_segmentation import predict_multiple

predict_multiple(
checkpoints_path="checkpoints/vgg_unet_1",
inp_dir="dataset_path/images_prepped_test/",
out_dir="outputs/"
)

cannot import name 'predict_multiple'

cannot figure out what the problem is, any clues?

@eiraola eiraola closed this as completed Nov 18, 2019
@eiraola eiraola reopened this Nov 18, 2019
@eiraola
Copy link
Author

eiraola commented Nov 18, 2019

Sorry it was a clumsy mistake, I forgot to put predict. before both functions :)

@eiraola eiraola closed this as completed Nov 18, 2019
@MuhammadAsadJaved
Copy link

Sorry it was a clumsy mistake, I forgot to put predict. before both functions :)

How did you resolve this issue? I have same problem.

@MuhammadAsadJaved
Copy link

Sorry it was a clumsy mistake, I forgot to put predict. before both functions :)

What do you mean by "put predict before both function" ?

@MuhammadAsadJaved
Copy link

I have resolved this problem. we should import like this.
#Predict one picture
from keras_segmentation.predict import predict

predict(
checkpoints_path="/home/lab/image-segmentation-keras/checkpoints/pspnet50_ade20k.h5",
inp="images_test/input_image.jpg",
out_fname="output_image.png"
)

#Predict multiple images in a directory

from keras_segmentation.predict import predict_multiple

predict_multiple(
checkpoints_path="checkpoints/vgg_unet_1",
inp_dir="images_test/",
out_dir="outputs/"
)

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Nov 30, 2019 via email

@AKASH2907
Copy link

You can just do it by the name of json file that is being saved in ur checkpoints directory. I figured it out after posting that's why deleted my comment.
If ur json file is saved as vgg-net_config.json just pass vgg-net and it will automatically pick up the best weight corresponding to that json file.

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Dec 1, 2019 via email

@AKASH2907
Copy link

No, that's not what you have to do. As you train the model, weights get saved in the folder you specify with the specific name as vgg_unet_1.1, vgg_unet_1.2, etc. for each epoch and a json file named as vgg_unet_1_config.json.
When you predict, give the checkpoints_path+vgg_unet_1 as an argument, then the network will start predicting.

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Dec 2, 2019 via email

@AKASH2907
Copy link

If u dont train it, how r u expecting to get json file and all. What are you trying to give till now at the checkpoints path?? Read the readme file bro.
Checkpoints can't be created without training.

@MuhammadAsadJaved
Copy link

Oh ok Thank you. but I was just try to run the demo using pre trained models as mentioned in the readme file. They did not mentioned to generate .json file. so i thought it only .h5 weights and rest of the files are already available.

@AKASH2907
Copy link

Nah for running also you need to have some checkpoint file and for that you need to train the model. Vgg_unet will automatically download and upload the weights for vgg16 network

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Dec 3, 2019 via email

@aneeqahazmat
Copy link

I am unable to read my training data , although training images and maska has data (image) still it gives assertion error.

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