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

ValueError: Unknown layer: BilinearUpSampling2D #19

Open
mahemon opened this issue Jul 14, 2017 · 5 comments
Open

ValueError: Unknown layer: BilinearUpSampling2D #19

mahemon opened this issue Jul 14, 2017 · 5 comments

Comments

@mahemon
Copy link

mahemon commented Jul 14, 2017

Dear @JihongJu thank you very much for sharing your code work. The train.py is running smoothly. After that, I want to run the infer.py, then the following line raise an error like this "ValueError: Unknown layer: BilinearUpSampling2D"

model = load_model('output/fcn_vgg16_weights.h5',
custom_objects={'CroppingLike2D': CroppingLike2D,
#'mean_categorical_crossentropy': mean_categorical_crossentropy})
'flatten_categorical_crossentropy': flatten_categorical_crossentropy(classes=21)})

I have tried to find out a solution but I can't make it right. could you please suggest me a way to solve this error.
One more thing, Do I need to write a new python file for call the score.py files method or somethings else?

Thanks in advanced

@JihongJu
Copy link
Owner

Hi @LetsExplore11, that is because BilinearUpSampling2D is a custom layer. You need to pass it as an argument to the load_model. I've updated the infer.py script on master and now it should work.

@mahemon
Copy link
Author

mahemon commented Jul 14, 2017

Hi @JihongJu Thank you. I am completely new in keras. So I have some common questions.

  1. Do I call the methods of score.py from infer.py to calculate the mean_IU? Would you please give me an example how to call the mean_IU method
  2. Do I need to write another file to run test files?

@JihongJu
Copy link
Owner

@LetsExplore11 I haven't tested the metrics in score.py and they were implemented with numpy, meaning that they cannot be compiled with the keras model as one of the monitoring metrics. But you can use the infer script to predict segmentation for each of the images once you have a trained model and call, for example, mean_IU by feeding the prediction and the label as numpy arrays.

@mahemon
Copy link
Author

mahemon commented Jul 14, 2017

Hi @JihongJu Thanks for your quick reply. As I am new in keras, So I do not fully understand your explanation. I beg a pardon for this reason. Could you please suggest me some way to make a way.

@JihongJu
Copy link
Owner

JihongJu commented Jul 15, 2017

@LetsExplore11 Ok. The current mean_IU has nothing to do with keras. It is a function manipulating numpy arrays. You can use a trained model to predict the segmentation. Once you have the segmentation, you can use the mean_IU function to compute mean IU. Maybe you can refer to the keras documentation for how to predict with a trained model.

@JihongJu JihongJu reopened this Jul 15, 2017
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

2 participants