Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Execution error #59

Open
songkovong opened this issue Mar 13, 2020 · 5 comments
Open

Execution error #59

songkovong opened this issue Mar 13, 2020 · 5 comments

Comments

@songkovong
Copy link

When I train the model and try the model with 'classify-hangul.py', I get the following error:

ValueError: Cannot feed value of shape (4096,) for Tensor 'hangul-model / input: 0', which has shape '(?, 4096)'.

If I ignore this problem and run it with 'optimized_hangul_tensorflow.pb' in the android asset folder, I get the following error:

java.lang.RuntimeException: Error loading pre-trained model.
Caused by: java.lang.RuntimeException: Failed to load model from 'new_hangul.pb'
Caused by: java.io.IOException: Not a valid TensorFlow Graph serialization: NodeDef mentions attr 'explicit_paddings' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: {{node Conv2D}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).

How can I solve this problem?

@pvaneck
Copy link
Contributor

pvaneck commented Mar 14, 2020

For the first issue, I think something with API changed that altered the shape of the input image. I will push an update. But seems like all you need to do is change the reshape line (line 26) to image = tf.reshape(image, (1, 64*64)). Thanks for bringing this up.

For the second issue, I am not too sure, I was able to build and run the app okay with the latest Android Studio and supported gradle version (5.6.4). Try seeing if you have the latest versions. I will also push a commit updating the version in the gradle build file.

@songkovong
Copy link
Author

Thanks for the answer.
The first problem was solved.
You think the second one is a version problem?
I'll finish the other work and try.

@songkovong
Copy link
Author

@pvaneck I'm sorry to ask you same problem.

캡처

I changed gradle version like this. But I have the same problem. In my opinion, maybe it is a pb file loading problem. Is there any other solution? I'll wait your answer :)

@pvaneck
Copy link
Contributor

pvaneck commented Mar 17, 2020

Sorry, I was using the optimized_hangul_tensorflow.pb file already contained in the Android folder (https://github.com/IBM/tensorflow-hangul-recognition/blob/master/hangul-tensordroid/app/src/main/assets/optimized_hangul_tensorflow.pb) which does work since it was trained using an older version of TF.

I did get the same error when trying to use the model just trained with a fresh install. Seems like it has to do with a version mismatch between the Python TensorFlow and the Android TensorFlow AAR file. Version 1.15.2 of TF is used while the highest version available for the TensorFlow AAR is 1.13.1 for the TensorFlow AAR.

My suggestion is to use the 1.13.1 version of TF for training and saving. Sorry about that! I went ahead
and pinned the TF version for now. I hope to soon update this project to use TF 2+ and TF Lite for the Android portion.

@songkovong
Copy link
Author

Thank you very much for the answer. My tensorflow version is 1.15.2, but there is no way to apply this version. I should try again with 1.13.1 :)

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

No branches or pull requests

2 participants