Restoring SSDLite-MobileNetV2: Variable [FeatureExtractor/MobilenetV2/Conv_1/weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1, 1, 320, 1280]], model variable shape: [[1, 1, 320, 256]].
System information
- What is the top-level directory of the model you are using: object_detection
- Have I written custom code: no
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 1.10.
- Bazel version (if compiling from source): -
- CUDA/cuDNN version: CUDA 9
- GPU model and memory: 1080Ti, 12GB
- Exact command to reproduce: fine-tuning pre-trained ssdlite_mobilenet_v2_coco_2018_05_09 using object_detection/model_main.py.
Describe the problem
MobileNetV2 was adapted to FPN and then the last 1x1 convolution 320->1280 was modified to 320->256 in here (where the original is here). For some reason, when trying to use the original MobileNetV2 architecture, for example for SSDLite, without FPN, the created MobiletNetV2 model still has 256 channels instead of 1280. In particular, it's not possible to restore the checkpoint of ssdlite_mobilenet_v2_coco_2018_05_09 correctly, since the affected variables (Conv_1, BoxPredictor_1) have different shapes (see log below). How can this be fixed? Thanks in advance.
Source code / logs
Relevant part of config file (no FPN):
model{
ssd {
feature_extractor {
type: "ssd_mobilenet_v2"
use_depthwise: true
...
}
...
}
}
Relevant logs:
W1024 12:42:45.373856 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor/weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1, 1, 1280, 24]], model variable shape: [[1, 1, 256, 24]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.373960 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor_depthwise/BatchNorm/beta] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374017 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor_depthwise/BatchNorm/gamma] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374068 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor_depthwise/BatchNorm/moving_mean] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374116 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor_depthwise/BatchNorm/moving_variance] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374166 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/BoxEncodingPredictor_depthwise/depthwise_weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[3, 3, 1280, 1]], model variable shape: [[3, 3, 256, 1]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374217 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor/weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1, 1, 1280, 546]], model variable shape: [[1, 1, 256, 546]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374266 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor_depthwise/BatchNorm/beta] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374312 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor_depthwise/BatchNorm/gamma] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374356 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor_depthwise/BatchNorm/moving_mean] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374400 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor_depthwise/BatchNorm/moving_variance] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.374447 139928539354880 variables_helper.py:141] Variable [BoxPredictor_1/ClassPredictor_depthwise/depthwise_weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[3, 3, 1280, 1]], model variable shape: [[3, 3, 256, 1]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.375486 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/Conv_1/BatchNorm/beta] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.375534 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/Conv_1/BatchNorm/gamma] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.375581 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/Conv_1/BatchNorm/moving_mean] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.375628 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/Conv_1/BatchNorm/moving_variance] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1280]], model variable shape: [[256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.375663 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/Conv_1/weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1, 1, 320, 1280]], model variable shape: [[1, 1, 320, 256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.378014 139928539354880 variables_helper.py:141] Variable [FeatureExtractor/MobilenetV2/layer_19_1_Conv2d_2_1x1_256/weights] is available in checkpoint, but has an incompatible shape with model variable. Checkpoint shape: [[1, 1, 1280, 256]], model variable shape: [[1, 1, 256, 256]]. This variable will not be initialized from the checkpoint.
W1024 12:42:45.379024 139928539354880 variables_helper.py:144] Variable [global_step] is not available in checkpoint
ah that explain my problem with that net.
Glad to hear I'm not the only one.
I have the same problem.
Same problem here...
@robieta
I have the same problem. And if i forced to go on training as the warning doesn't stop the training , I can get the .ckpt checkpoint.
But I got an error when I run test.py by using the checkpoint:
Traceback (most recent call last):
File "test_tf.py", line 40, in
my "test.py" is as follows: `
with tf.Session() as sess:
saver = tf.train.import_meta_graph('models/my_train/model.ckpt.meta')
saver.restore(sess, 'models/my_train/model.ckpt')
image_tensor = sess.graph.get_tensor_by_name('image_tensor:0')
boxes = sess.graph.get_tensor_by_name('detection_boxes:0')
scores = sess.graph.get_tensor_by_name('detection_scores:0')
cls = sess.graph.get_tensor_by_name('detection_classes:0')
num_detections = sess.graph.get_tensor_by_name('num_detections:0')
image = cv2.imread("data/Image_16.jpg")
image_data = np.expand_dims(image, axis=0).astype(np.uint8)
print(image_data.shape)
(box, score, clses, num_detection) = sess.run([boxes, scores, cls, num_detections], {image_tensor:image_data})
boxes = box[0]
scores = score[0]
classes = clses[0]
num_detections = num_detection[0]
print("the count of objects is: ", num_detections)
im_width = image.shape[1]
im_height = image.shape[0]
for i in range((int)(num_detections)):
print("object ", i, " class id: " , classes[i], " score: " , scores[i], " boxes: ", boxes[i])
y_min = (int)(boxes[i][0] * im_height)
x_min = (int)(boxes[i][1] * im_width)
y_max = (int)(boxes[i][2] * im_height)
x_max = (int)(boxes[i][3] * im_width)
x = int((x_min + x_max) / 2)
y = int((y_min + y_max) / 2)
cv2.rectangle(image, (x_min, y_min), (x_max, y_max), (0, 0, 255), 2)
cv2.imshow("result", image)
cv2.waitKey(0)
`
so , I print all tensor.name in checkpoint, it is true that there is no such tensor
why?
Allegedly fixed in a https://github.com/tensorflow/models/pull/5613/commits/449408bb20cdd11eb24039f092a4d8602cfe7ca5 on the latest pull (haven't checked yet). Closing For now, and will reopen if necessary.