squeezeDet icon indicating copy to clipboard operation
squeezeDet copied to clipboard

Checkpoints other than squeezeDet don't work for the demo

Open dsavenko opened this issue 7 years ago • 4 comments

Hi,

I've done installation, and trying to do the demo as described in README. I downloaded model_checkpoints.tgz, untar it. Now, I'm running python ./src/demo.py. It works as expected with the default parameters. But if I try to specify any other checkpoints from model_checkpoints, it doesn't work. E.g. if I do this:

python ./src/demo.py --checkpoint=./data/model_checkpoints/squeezeDetPlus/model.ckpt-95000

I get the following error:

$ python ./src/demo.py --checkpoint=./data/model_checkpoints/squeezeDetPlus/model.ckpt-95000
2017-05-30 18:09:07.901895: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-30 18:09:07.901920: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-30 18:09:07.901926: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-30 18:09:07.901941: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-30 18:09:07.901946: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
  File "./src/demo.py", line 217, in <module>
    tf.app.run()
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "./src/demo.py", line 212, in main
    image_demo()
  File "./src/demo.py", line 164, in image_demo
    saver.restore(sess, FLAGS.checkpoint)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1457, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run
    run_metadata_ptr)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 982, in _run
    feed_dict_string, options, run_metadata)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
    target_list, options, run_metadata)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [64] rhs shape= [96]
	 [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@conv1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](conv1/biases, save/RestoreV2)]]

Caused by op u'save/Assign', defined at:
  File "./src/demo.py", line 217, in <module>
    tf.app.run()
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "./src/demo.py", line 212, in main
    image_demo()
  File "./src/demo.py", line 161, in image_demo
    saver = tf.train.Saver(model.model_params)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1056, in __init__
    self.build()
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1086, in build
    restore_sequentially=self._restore_sequentially)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 691, in build
    restore_sequentially, reshape)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 419, in _AddRestoreOps
    assign_ops.append(saveable.restore(tensors, shapes))
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 155, in restore
    self.op.get_shape().is_fully_defined())
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 270, in assign
    validate_shape=validate_shape)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 47, in assign
    use_locking=use_locking, name=name)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/dsavenko/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [64] rhs shape= [96]
	 [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@conv1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](conv1/biases, save/RestoreV2)]]

Is it expected?

dsavenko avatar May 30 '17 11:05 dsavenko

Thanks for letting me know. Seems that it's broken by a recent update. I'll fix that later.

BichenWuUCB avatar May 30 '17 17:05 BichenWuUCB

Please check-out the newest commit. Now demo.py can also load SqueezeDet+. But you need to use the flag --demo_net=squeezeDet+ and --checkpoint=./data/model_checkpoints/squeezeDetPlus/model.ckpt-95000 together so it can load the right model specification and parameters.

BichenWuUCB avatar May 30 '17 20:05 BichenWuUCB

Works great, thank you! I did similar to what you've done for Resnet50 and VGG16 in this PR: #50. Could you please validate and change the net classes if necessary (I've only modified demo.py)?

dsavenko avatar May 31 '17 04:05 dsavenko

@BichenWuUCB Hi, I try to download the model_checkpoints from your github, but when I click the hyperlink, I can't visit the paper. I would appreciate if you can send me the model_checkpoints file. My emali:[email protected]

thomas3016 avatar Feb 01 '18 01:02 thomas3016