tensorflow / models

Models and examples built with TensorFlow
Other
76.94k stars 45.79k forks source link

retrained tfslim mobilenet_v1 model does not have input node? #3508

Closed springishere closed 5 years ago

springishere commented 6 years ago

System information

nvidia-docker run -v ~/DataSets:/DataSets -v ~/tensorflow:/tensorflow -it gcr.io/tensorflow/tensorflow:latest-gpu-py3 bash Here DataSets are tfrecords formatted images, tensorflow is the tensorflow

Then within the docker image:

  1. train: DATASET_DIR=/DataSets/ mkdir /tmp/logs TRAIN_DIR=/tmp/logs cd /tensorflow/models/research/slim python train_image_classifier.py --train_dir=${TRAIN_DIR} --dataset_name=imagenet --dataset_split_name=train --dataset_dir=${DATASET_DIR} --model_name=mobilenet_v1
  2. frozen pb: cd /usr/local/lib/python3.5/dist-packages/tensorflow/python/tools python freeze_graph.py --input_graph=/tmp/logs/graph.pbtxt --input_checkpoint=/tmp/logs/model.ckpt-102638 --output_graph=/tmp/mobilenet_v1_224_frozen_trained.pb --output_node_names=MobilenetV1/Predictions/Reshape_1

Describe the problem

This frozen pb does not have input node. I tried with summary_graph.py, it says "No inputs spotted." (the summary_graph.py is on another desktop with python 2.7, but I assume the model once frozen should be portable) Also tried another tool, it complains the same thing.

angerson commented 6 years ago

@sguada Can you take a look at this?

springishere commented 6 years ago

one data point is that in the mobilenet_v1test.py an input placeholder is added in testUnknowBatchSize(): inputs = tf.placeholder(tf.float32, (None, height, width, 3)) logits, = mobilenet_v1.mobilenet_v1(inputs, num_classes) So maybe this is expected? I am not sure if this is the right procedure to modify the pb file (restore, add placeholder, and store) --- if this is needed please give a code example to use. Thanks!

haoxi911 commented 6 years ago

@fye881 @angersson Any updates on this issue?

I am facing the same problem, after fine-tuning mobilenet_v1 on my own dataset (Oxford IIIT Pet), the new protocol buffer file was created by can't be used with label_image sample, same error as @fye881 mentioned:

(tensorflow) ubuntu@haoxi911:~/tensorflow/models/research/slim$ python train_image_classifier.py 
--train_dir=/tmp/oxford-iiit-pet/mobile_v1_1.0_224_finetune 
--dataset_dir=/tmp/oxford-iiit-pet 
--dataset_name=oxford_iiit_pets 
--dataset_split_name=train 
--model_name=mobilenet_v1 
--checkpoint_path=/tmp/mobilenet_v1_1.0_224_downloaded/mobilenet_v1_1.0_224.ckpt  
--checkpoint_exclude_scopes=MobilenetV1/Logits 
--trainable_scopes=MobilenetV1/Logits 
--max_number_of_steps=1000

(tensorflow) ubuntu@haoxi911:~/tensorflow/tensorflow/tensorflow/python/tools$ python freeze_graph.py 
--input_graph=/tmp/oxford-iiit-pet/mobile_v1_1.0_224_finetune/graph.pbtxt 
--input_binary=false 
--input_checkpoint=/tmp/oxford-iiit-pet/mobile_v1_1.0_224_finetune/model.ckpt-1000 
--output_graph=/tmp/oxford-iiit-pet/mobile_v1_1.0_224_finetune/frozen_graph.pb 
--output_node_names=MobilenetV1/Predictions/Reshape_1

(tensorflow) ubuntu@haoxi911:~/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image
--input_layer=input   
--output_layer=MobilenetV1/Predictions/Reshape_1   
--graph=/tmp/oxford-iiit-pet/mobile_v1_1.0_224_finetune/frozen_graph.pb
--input_mean=-127 
--input_std=127  
--image=tensorflow/examples/label_image/data/grace_hopper.jpg
--input_width=224 
--input_height=224 
--labels=/tmp/mobilenet_v1_1.0_224/labels.txt 

The error message is:

2018-03-14 18:25:24.120569: E tensorflow/examples/label_image/main.cc:349] Running model failed: Not found: FeedInputs: unable to find feed output input

springishere commented 6 years ago

you can use the export_inference_graph.py to generate mobilenet_v1 which has input node.

wt-huang commented 5 years ago

Closing as this is resolved