Tencent / tencent-ml-images

Largest multi-label image database; ResNet-101 model; 80.73% top-1 acc on ImageNet
Other
3.06k stars 515 forks source link

checkpoint ckpt-resnet101-mlimages 图片分类报错 #62

Closed linghaolu closed 4 years ago

linghaolu commented 4 years ago

下载 ckpt-resnet101-mlimages from googledrive 采用 example 中的 分类python代码报错

Traceback (most recent call last): File "image_classification.py", line 74, in saver.restore(sess, FLAGS.model_dir) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1312, in restore err, "a mismatch between the current graph and the graph") tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered $he graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [1000] rhs shape= [11166] [[node save/Assign_5 (defined at image_classification.py:73) ]]

Caused by op u'save/Assign_5', defined at: File "image_classification.py", line 73, in saver = tf.train.Saver(tf.global_variables()) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 832, in init self.build() File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 844, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 881, in _build build_save=build_save, build_restore=build_restore) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 513, in _build_internal restore_sequentially, reshape) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 354, in _AddRestoreOps assign_ops.append(saveable.restore(saveable_tensors, shapes)) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 73, in restore self.op.get_shape().is_fully_defined()) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign validate_shape=validate_shape) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign use_locking=use_locking, name=name) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/work/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expe$ted based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [1000] rhs shape= [11166] [[node save/Assign_5 (defined at image_classification.py:73) ]]

linghaolu commented 4 years ago

下载的 ckpt-resnet101-mlimages-imagenet 运行没有问题

linghaolu commented 4 years ago

知道了。flag 中一些参数是根据 imagenet 设置的

linghaolu commented 4 years ago

通过修改配置,另外缺少一个 dictionary,需要自己导出一下 就可以了。

akofman commented 4 years ago

@linghaolu could you explain what flags did you change and how did you build this new dictionary ? Thx !

linghaolu commented 4 years ago

@linghaolu could you explain what flags did you change and how did you build this new dictionary ? Thx !

the 'class_num' in flags.py. change it from 1000 to 11166. 1000 is for the class num of imagenet. 11166 is for ml_images.

and you also need to generate a data/mlimages_dictionary.txt file like data/imagenet2012_dictionary.txt which is needed in example/image_classification.sh

akofman commented 4 years ago

It works ! 谢谢 👍

chenzhengnan commented 3 years ago

请问你imagenet的整个数据库是怎么获取的 谢谢 @linghaolu