How to use resnet instead of vgg16
See original GitHub issueWARNING:tensorflow:From H:\MachineLearning\match\text-detection-ctpn-banjin-dev\text-detection-ctpn-banjin-dev\nets\resnet_v2.py:213: calling reduce_mean (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Traceback (most recent call last): File “./main/train.py”, line 122, in <module> tf.app.run() File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py”, line 125, in run _sys.exit(main(argv)) File “./main/train.py”, line 49, in main bbox_pred, cls_pred, cls_prob = model.model(input_image) File “H:\MachineLearning\match\text-detection-ctpn-banjin-dev\text-detection-ctpn-banjin-dev\nets\model_train.py”, line 72, in model rpn_conv = slim.conv2d(conv5_3, 512, 3) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py”, line 183, in func_with_args return func(*args, **current_args) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py”, line 1154, in convolution2d conv_dims=2) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py”, line 183, in func_with_args return func(*args, **current_args) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py”, line 1020, in convolution inputs = ops.convert_to_tensor(inputs) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py”, line 998, in convert_to_tensor as_ref=False) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py”, line 1094, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py”, line 961, in _autopacking_conversion_function return _autopacking_helper(v, inferred_dtype, name or “packed”) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py”, line 923, in _autopacking_helper constant_op.constant(elem, dtype=dtype, name=str(i))) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py”, line 196, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py”, line 436, in make_tensor_proto _AssertCompatible(values, dtype) File “D:\Anaconda\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py”, line 347, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).name)) TypeError: Expected float32, got OrderedDict([(‘resnet_v2_50/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/conv1/BiasAdd:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_1/bottleneck_v2/shortcut’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_1/bottleneck_v2/shortcut/BiasAdd:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_1/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_1/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_1/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_1/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_1/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_1/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_1/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_1/bottleneck_v2/add:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_2/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_2/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_2/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_2/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_2/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_2/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_2/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_2/bottleneck_v2/add:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_3/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_3/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_3/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_3/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 64) dtype=float32>), (‘resnet_v2_50/block1/unit_3/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_3/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1/unit_3/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block1’, <tf.Tensor ‘model_0/resnet_v2_50/block1/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block2/unit_1/bottleneck_v2/shortcut’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_1/bottleneck_v2/shortcut/BiasAdd:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_1/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_1/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_1/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_1/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_1/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_1/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_1/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_1/bottleneck_v2/add:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_2/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_2/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_2/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_2/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_2/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_2/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_2/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_2/bottleneck_v2/add:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_3/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_3/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_3/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_3/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_3/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_3/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_3/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_4/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_4/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_4/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_4/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 128) dtype=float32>), (‘resnet_v2_50/block2/unit_4/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_4/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2/unit_4/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_4/bottleneck_v2/add:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block2’, <tf.Tensor ‘model_0/resnet_v2_50/block2/unit_4/bottleneck_v2/add:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block3/unit_1/bottleneck_v2/shortcut’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_1/bottleneck_v2/shortcut/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_1/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_1/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_1/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_1/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_1/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_1/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_1/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_1/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_2/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_2/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_2/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_2/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_2/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_2/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_2/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_2/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_3/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_3/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_3/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_3/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_3/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_3/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_3/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_4/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_4/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_4/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_4/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_4/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_4/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_4/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_4/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_5/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_5/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_5/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_5/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_5/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_5/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_5/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_5/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_6/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_6/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_6/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_6/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 256) dtype=float32>), (‘resnet_v2_50/block3/unit_6/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_6/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3/unit_6/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_6/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block3’, <tf.Tensor ‘model_0/resnet_v2_50/block3/unit_6/bottleneck_v2/add:0’ shape=(?, ?, ?, 1024) dtype=float32>), (‘resnet_v2_50/block4/unit_1/bottleneck_v2/shortcut’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_1/bottleneck_v2/shortcut/BiasAdd:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_1/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_1/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_1/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_1/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_1/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_1/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_1/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_1/bottleneck_v2/add:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_2/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_2/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_2/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_2/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_2/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_2/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_2/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_2/bottleneck_v2/add:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_3/bottleneck_v2/conv1’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_3/bottleneck_v2/conv1/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_3/bottleneck_v2/conv2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_3/bottleneck_v2/conv2/Relu:0’ shape=(?, ?, ?, 512) dtype=float32>), (‘resnet_v2_50/block4/unit_3/bottleneck_v2/conv3’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_3/bottleneck_v2/conv3/BiasAdd:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4/unit_3/bottleneck_v2’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘resnet_v2_50/block4’, <tf.Tensor ‘model_0/resnet_v2_50/block4/unit_3/bottleneck_v2/add:0’ shape=(?, ?, ?, 2048) dtype=float32>), (‘global_pool’, <tf.Tensor ‘model_0/resnet_v2_50/pool5:0’ shape=(?, 1, 1, 2048) dtype=float32>)]) of type ‘OrderedDict’ instead.
The screen shows these when I run the modified file
"train.py" line 22
tf.app.flags.DEFINE_string('pretrained_model_path', 'data/vgg_16.ckpt', '')
to
tf.app.flags.DEFINE_string('pretrained_model_path', 'data/resnet_v2_50.ckpt', '')
"model_train.py" line 5
from nets import vgg
to
from nets import resnet_v2, resnet_utils
line 68,69
with slim.arg_scope(vgg.vgg_arg_scope()):
conv5_3 = vgg.vgg_16(image)
to
with slim.arg_scope(resnet_utils.resnet_arg_scope()):
conv5_3 = resnet_v2.resnet_v2_50(image)
that’s all i modified i would appreciate it if you could help me. @eragonruan
Issue Analytics
- State:
- Created 4 years ago
- Comments:24
Top GitHub Comments
try this: with slim.arg_scope(resnet_v1.resnet_arg_scope()): net , end_points = resnet_v1.resnet_v1_50(image, num_classes=None, is_training=False) conv5_3 = end_points[‘resnet_v1_50/block3/unit_4/bottleneck_v1/conv2’]
The network runs well but without convergence.
@bagpeng 时间有点长了 我也不确定对不对 就是我这篇issue里 进行的前两个操作+ 第三个操作改成 with slim.arg_scope(resnet_v1.resnet_arg_scope()): net , end_points = resnet_v1.resnet_v1_50(image, num_classes=None, is_training=False) conv5_3 = end_points[‘resnet_v1_50/block3/unit_4/bottleneck_v1/conv2’] 当然 end_point里的参数需要你自己去找 上面这楼写了
不建议resnet 因为vgg综合效果更好