-
Notifications
You must be signed in to change notification settings - Fork 45.8k
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
can't import pretrained mobilenet model #1564
Comments
same issue on mac, tf version 1.2.0 |
@korrawat , do you have any thoughts on what is causing this? |
I'm also getting this on Ubuntu, TF 1.2.0. As a work-around, I also tried to use the slim library definitions and restore the variables. I have been able to save (and test) frozen models for the 4 1.0 files, but on 0.75/0.50/0.25 models, I get errors (see this gist for all output) due to dimension mismatches, e.g.:
The code that I used can be found at this gist (tested with Python 3 + TF 1.2.0). You just need to edit it to have the EDIT: Nevermind, it looks like I was not passing in the depth_multiplier variable (I overlooked it, as there is no mechanism for it using nets_factory). I have updated the gist and it seems to work. |
@aselle, I got the same error on Ubuntu, TF 1.2.0. I'm not really sure why the checkpoint files don't work either. |
@korrawat , Is the current slim MobileNet code the same code that was used to create those checkpoints? Otherwise, I don't understand what could be the issue with my restoring code. If you have a chance to look at that, I'd appreciate it. |
Looking into this. |
To get rid of the |
@futurely , Have you tried this approach with the non-1.0 MobileNets? I get errors due to incompatible dimensions (see my previous post for gist link). EDIT: Nevermind, it looks like I was not passing in the depth_multiplier variable (I overlooked it, as there is no mechanism for it using nets_factory). I have updated the code and it seems to work. |
Take a look #1702 |
After generating *.pb files by gist from @StanislawAntol and placing it to *.ckpt files I was able to load weight. |
@NickShargan I have generated the *.pb file, what do you mean by placing it to the *.ckpt files and how did you do so? |
Hi, I have the same error in ubuntu16.04, tensorflow1.2, have your guys fixed your problem? |
Hi, I'am getting the same error on win10, tf 1.2. Anyone got a solution? |
i have the same porblem~Anyone fixed it? |
@StanislawAntol can you be more precise on the process you follow ? |
@kmonachopoulos, I'm not sure how much more precise I can be than the gist posted above. You just need to edit it to have the |
Sorry, it was just a path error I missed, it is working, thanks |
@kmonachopoulos, no worries. I guess I technically updated the code and hadn't editet the comment to reflect this. It's fixed now to be clearer. |
@StanislawAntol Thanks for the gist code. So what are we supposed to do after generating the .pb files? |
@amirjamez, It contains the model so you can load it, feed in input (i.e., images), and get classification results, e.g., something like this C++ code or this Python code. |
@StanislawAntol, Yes, but I would like to see the weights related to each layer, and more importantly, the final layer's weights. Can we do that using the .pb files? If so, could you kindly provide a MWE? |
@amirjamez, GitHub Issues is not the appropriate place for those kind of questions. Places like StackOverflow are more appropriate (as stated in the README). I haven't touched TensorFlow in a while, but I'm sure you can do it. This post might be helpful, though you might have to be aware that the frozen graph (e.g., the output of my gist) has all the weights as constants, not trainable variables. |
@StanislawAntol , freeze_mobilenet.py as in gist would not work. The models git repo structure has changed with the latest version in https://github.com/tensorflow/models.git. Can you please help to provide newer freeze_mobilenet.py version that is compatible with the newer repo structure. |
@ra9hur , All that was needed is to provide the correct path to the slim directory. I have updated the gist so it accepts a command-line argument for the
|
@StanislawAntol , Thanks for changes to the script. Was able to generate .pb with the following changes.
Locally, after git cloning models and MobileNet repos, the structure would be:
|
@ra9hur, you shouldn't have needed to do anything but provide the path (e.g., /home/ra9hur/tf/models) at the command line. It should have created a |
@StanislawAntol , initially did try that, but was getting error for missing 'Labels.json' file. I was trying multiple options and must have overlooked something. Thanks again. |
Are you sure you were running the newest gist code? I just copied it into a new directory, installed TF1.3 into a new virtual environment (running Python3), cloned the |
OK, to declutter a bit. Of the 3 errors,
May be, if I had not copied MobileNet manually, the newer script would have created this folder for me. Hope, that clarifies. EDIT: @StanislawAntol , had to create frozen weights again with spatial_squeeze=False. Tried running the script while removing 'MobileNet' folder. To confirm, new script creates 'MobileNet' folder, copies 'Labels.json' file into the folder and works as-is. |
I am facing the same issue and have been trying to fix it since hours. I don't have a fast internet access right now and hence would like to know if anyone has a solution without having to download tensorflow/models ? |
I had a similar problem with tensorflow 1.2, and when i update tensorflow to version 1.4, the problem was solved. Hope it helps:) |
Same error with vanilla TF 1.4 but the gist posted above worked perfectly for me so problem solved thanks. |
I download mobilenet_v1_1.0_224_2017_06_14.tar.gz and untar it and then use the following code to import it.
import tensorflow as tf
from tensorflow.contrib import layers
with tf.Session() as sess:
tf.contrib
saver = tf.train.import_meta_graph('./tmp/mobilenet_v1_1.0_224.ckpt.meta')
However, I got the following error. Any idea why this error happens.
Traceback (most recent call last):
File "./restore.py", line 9, in
saver = tf.train.import_meta_graph('./tmp/mobilenet_v1_1.0_224.ckpt.meta')
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1683, in import_meta_graph
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/meta_graph.py", line 499, in import_scoped_meta
producer_op_list=producer_op_list)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 280, in import_graph_def
raise ValueError('No op named %s in defined operations.' % node.op)
ValueError: No op named SSTableReaderV2 in defined operations.
My tensorflow version: 1.1.0-rc1
Thanks,
The text was updated successfully, but these errors were encountered: