ValueError: Variable vgg_16/conv1/conv1_1/weights already exists, disallowed

参考链接:

https://stackoverflow.com/questions/44978210/valueerror-variable-vgg-16-conv1-conv1-1-weights-already-exists-disallowed

https://bbs.csdn.net/topics/392277761

问题描述:

在windows端使用Flask+Apache+WSGI+tf-faster-rcnn+winform,所有环境配置好后,重启Apache开始检测,第一次检测时,检测结果正常输出,第二检测时就开始报500错误,查看Apache错误日志,如下:

[Mon Oct 29 14:20:17.120980 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] totalNum 0\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] [2018-10-29 14:20:23,511] ERROR in app: Exception on /postdata [POST]\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] Traceback (most recent call last):\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\app.py", line 2292, in wsgi_app\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     response = self.full_dispatch_request()\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\app.py", line 1815, in full_dispatch_request\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     rv = self.handle_user_exception(e)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\app.py", line 1718, in handle_user_exception\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     reraise(exc_type, exc_value, tb)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\_compat.py", line 35, in reraise\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     raise value\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\app.py", line 1813, in full_dispatch_request\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     rv = self.dispatch_request()\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\flask\\app.py", line 1799, in dispatch_request\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return self.view_functions[rule.endpoint](**req.view_args)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "D:/Faster-RCNN-TensorFlow-Python3.5-Cell\\ssh_demo.py", line 192, in postdata\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     net.create_architecture(sess, "TEST", 20, tag='default', anchor_scales=[8, 16, 32])\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "D:/Faster-RCNN-TensorFlow-Python3.5-Cell\\lib\\nets\\network.py", line 298, in create_architecture\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     rois, cls_prob, bbox_pred = self.build_network(sess, training)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "D:/Faster-RCNN-TensorFlow-Python3.5-Cell\\lib\\nets\\vgg16.py", line 29, in build_network\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     net = self.build_head(is_training)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "D:/Faster-RCNN-TensorFlow-Python3.5-Cell\\lib\\nets\\vgg16.py", line 92, in build_head\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     net = slim.repeat(self._image, 2, slim.conv2d, 64, [3, 3], trainable=False, scope='conv1')\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\layers\\python\\layers\\layers.py", line 2612, in repeat\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     outputs = layer(outputs, *args, **kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\arg_scope.py", line 182, in func_with_args\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return func(*args, **current_args)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\layers\\python\\layers\\layers.py", line 1154, in convolution2d\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     conv_dims=2)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\arg_scope.py", line 182, in func_with_args\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return func(*args, **current_args)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\layers\\python\\layers\\layers.py", line 1057, in convolution\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     outputs = layer.apply(inputs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\base_layer.py", line 828, in apply\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return self.__call__(inputs, *args, **kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\layers\\base.py", line 364, in __call__\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     outputs = super(Layer, self).__call__(inputs, *args, **kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\base_layer.py", line 759, in __call__\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     self.build(input_shapes)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\keras\\layers\\convolutional.py", line 161, in build\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     dtype=self.dtype)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\layers\\base.py", line 278, in add_weight\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     getter=vs.get_variable)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\base_layer.py", line 586, in add_weight\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\training\\checkpointable\\base.py", line 591, in _add_variable_with_custom_getter\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     **kwargs_for_getter)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\ops\\variable_scope.py", line 1484, in get_variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\ops\\variable_scope.py", line 1234, in get_variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\ops\\variable_scope.py", line 521, in get_variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return custom_getter(**custom_getter_kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\layers\\python\\layers\\layers.py", line 1749, in layer_variable_getter\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return _model_variable_getter(getter, *args, **kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\layers\\python\\layers\\layers.py", line 1740, in _model_variable_getter\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\arg_scope.py", line 182, in func_with_args\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return func(*args, **current_args)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\variables.py", line 350, in model_variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\arg_scope.py", line 182, in func_with_args\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return func(*args, **current_args)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\contrib\\framework\\python\\ops\\variables.py", line 277, in variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\ops\\variable_scope.py", line 492, in _true_getter\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     aggregation=aggregation)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\ops\\variable_scope.py", line 859, in _get_single_variable\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     name, "".join(traceback.format_list(tb))))\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] ValueError: Variable vgg_16/conv1/conv1_1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] \r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\framework\\ops.py", line 1768, in __init__\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     self._traceback = tf_stack.extract_stack()\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\framework\\ops.py", line 3272, in create_op\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     op_def=op_def)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]   File "c:\\anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow\\python\\util\\deprecation.py", line 488, in new_func\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118]     return func(*args, **kwargs)\r
[Mon Oct 29 14:20:23.511438 2018] [wsgi:error] [pid 5168:tid 1588] [client 113.247.57.193:18118] \r

滑到底部可以看到有一个明显的错误提示: ValueError: Variable vgg_16/conv1/conv1_1/weights already exists, disallowed.

经查找问题得知大概问题的原因是两次检测不能使用tensorflow旧的变量,解决办法是在重置图表,输入以下语句:

tf.reset_default_graph()

例如我就加在了开始检测的位置:

最后问题完全解决!

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LoveWeeknd

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值