tensorflow_目标识别object_detection_api,RuntimeError: main thread is not in main loop,fig = plt.figure(frameon=False)_tkinter.TclError: no display name and no $DISPLAY environment variable
最近在使用目标识别api,但是报错了:
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 158, in __call__
ret = func(*args)
File "/home/lyz/code/share_pro/models/research/object_detection/utils/visualization_utils.py", line 694, in cdf_plot
fig = plt.figure(frameon=False)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 98, in new_figure_manager_given_figure
icon_img = Tk.PhotoImage(file=icon_fname)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3370, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3324, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
Traceback (most recent call last):
File "object_detection/model_main.py", line 101, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "object_detection/model_main.py", line 97, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 447, in train_and_evaluate
return executor.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 531, in run
return self.run_local()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 669, in run_local
hooks=train_hooks)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 366, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1119, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1135, in _train_model_default
saving_listeners)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1336, in _train_with_estimator_spec
_, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 577, in run
run_metadata=run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 1053, in run
run_metadata=run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 1144, in run
raise six.reraise(*original_exc_info)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 1129, in run
return self._sess.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 1201, in run
run_metadata=run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 981, in run
return self._sess.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 900, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1135, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1316, in _do_run
run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1335, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: exceptions.RuntimeError: main thread is not in main loop
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 158, in __call__
ret = func(*args)
File "/home/lyz/code/share_pro/models/research/object_detection/utils/visualization_utils.py", line 694, in cdf_plot
fig = plt.figure(frameon=False)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 98, in new_figure_manager_given_figure
icon_img = Tk.PhotoImage(file=icon_fname)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3370, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3324, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
[[Node: Loss/PyFunc_1 = PyFunc[Tin=[DT_FLOAT], Tout=[DT_UINT8], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Loss/Squeeze_1/_6143)]]
Caused by op u'Loss/PyFunc_1', defined at:
File "object_detection/model_main.py", line 101, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "object_detection/model_main.py", line 97, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 447, in train_and_evaluate
return executor.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 531, in run
return self.run_local()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 669, in run_local
hooks=train_hooks)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 366, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1119, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1132, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1107, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "/home/lyz/code/share_pro/models/research/object_detection/model_lib.py", line 281, in model_fn
prediction_dict, features[fields.InputDataFields.true_image_shape])
File "/home/lyz/code/share_pro/models/research/object_detection/meta_architectures/ssd_meta_arch.py", line 597, in loss
flattened_class_ids, flattened_classification_losses)
File "/home/lyz/code/share_pro/models/research/object_detection/meta_architectures/ssd_meta_arch.py", line 660, in _summarize_anchor_classification_loss
'NegativeAnchorLossCDF')
File "/home/lyz/code/share_pro/models/research/object_detection/utils/visualization_utils.py", line 704, in add_cdf_image_summary
cdf_plot = tf.py_func(cdf_plot, [values], tf.uint8)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 384, in py_func
func=func, inp=inp, Tout=Tout, stateful=stateful, eager=False, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 227, in _internal_py_func
input=inp, token=token, Tout=Tout, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_script_ops.py", line 128, in py_func
"PyFunc", input=input, token=token, Tout=Tout, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3414, in create_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1740, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
UnknownError (see above for traceback): exceptions.RuntimeError: main thread is not in main loop
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 158, in __call__
ret = func(*args)
File "/home/lyz/code/share_pro/models/research/object_detection/utils/visualization_utils.py", line 694, in cdf_plot
fig = plt.figure(frameon=False)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 98, in new_figure_manager_given_figure
icon_img = Tk.PhotoImage(file=icon_fname)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3370, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3324, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
[[Node: Loss/PyFunc_1 = PyFunc[Tin=[DT_FLOAT], Tout=[DT_UINT8], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Loss/Squeeze_1/_6143)]]
Exception RuntimeError: 'main thread is not in main loop' in <bound method StringVar.__del__ of <Tkinter.StringVar instance at 0x7fe4a8e7bd40>> ignored
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.py", line 92, in destroy_all
manager.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 619, in destroy
self.window.destroy()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1862, in destroy
for c in self.children.values(): c.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 715, in destroy
Tk.Frame.destroy(self, *args)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2099, in destroy
for c in self.children.values(): c.destroy()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2100, in destroy
self.tk.call('destroy', self._w)
RuntimeError: main thread is not in main loop
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.py", line 92, in destroy_all
manager.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 619, in destroy
self.window.destroy()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1862, in destroy
for c in self.children.values(): c.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 715, in destroy
Tk.Frame.destroy(self, *args)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2099, in destroy
for c in self.children.values(): c.destroy()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2100, in destroy
self.tk.call('destroy', self._w)
RuntimeError: main thread is not in main loop
其实,网上说解决方法是加:
matplotlib.use('Agg')
但是代码里面:
# Set headless-friendly backend.
import matplotlib;matplotlib.use('Agg') # pylint: disable=multiple-statements
import matplotlib.pyplot as plt # pylint: disable=g-import-not-at-top
已经有了呀,很奇怪,最后面看到网上的解决方案:https://github.com/tensorflow/models/issues/4777
modified object_detection/eval_util.py
@@ -22,4 +22,5 @@ import numpy as np
import tensorflow as tf
+from object_detection.utils import visualization_utils as vis_utils
from object_detection.core import box_list
from object_detection.core import box_list_ops
@@ -29,5 +30,4 @@ from object_detection.metrics import coco_evaluation
from object_detection.utils import label_map_util
from object_detection.utils import ops
-from object_detection.utils import visualization_utils as vis_utils
然后就搞定了,把
from object_detection.utils import visualization_utils as vis_utils
这个放在第一个,这样就ok了,其实可能是调用的先后顺序问题
tensorflow_目标识别object_detection_api,RuntimeError: main thread is not in main loop,fig = plt.figure(frameon=False)_tkinter.TclError: no display name and no $DISPLAY environment variable的更多相关文章
- Why NSAttributedString import html must be on main thread?
The HTML importer should not be called from a background thread (that is, the options dictionary inc ...
- 13、主线程任务太多导致异常退出(The application may be doing too much work on its main thread)
今天花费了一天的时间来解决这个bug. 这种在程序运行期间出现的问题比较棘手,如果再没有规律的话就更难解决. 还好这个bug是由规律的,也就是说在程序执行半个小时左右后就会因为此异常而导致程序退出:那 ...
- reloadData should be in main thread
reloadData should be called in main thread, so if you call it in work thread, you should call it as ...
- main thread starting…
例的结果,下面的: main thread starting- Thrad 2 staring- Thrad 2 end- Thrad 4 staring- Thrad 4 end- Thrad 1 ...
- APP崩溃提示:This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
崩溃输出日志 2017-08-29 14:53:47.332368+0800 HuiDaiKe[2373:1135604] This application is modifying the auto ...
- Ajax.html:35 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org
AJAX的容易错误的地方 Ajax.html:35 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated ...
- 关于chrome控制台警告:Synchronous XMLHttpRequest on the main thread
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to th ...
- iOS Main Thread Checker: UI API called on a background thread的解释
Xcode打印栏出现如下警告: Main Thread Checker: UI API called on a background thread 这个是什么错误呢? 其实这并不一定是错误,也可以理解 ...
- jquery.js:8672 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
html5谷歌流浪器报错:jquery.js:8672 Synchronous XMLHttpRequest on the main thread is deprecated because of i ...
随机推荐
- Centos6.9部署Gitlab-11.9.8并汉化
Git 是一种分布式的代码版本管理系统,git在工作时可以不用时刻依赖后台服务器,在本地电脑上就可以管理版本控制,但是在需要协同开发时就必须要使用后台服务器了,目前互联网上有github,码云这样的远 ...
- 2、冒泡排序法(C语言)
一.冒泡算法实现分析 1.假设有5个元素分别为8,6,15,9,3对其进行冒泡排序,我们需要关注的有三点如下: (1)元素个数 n: (2)需要比较的趟数 i: (3)每趟比较的次数 j: 2.它们之 ...
- python数据类型(字符串、列表操作)
一.整形和浮点型整形也就是整数类型(int)的,在python3中都是int类型,没有什么long类型的,比如说存年龄.工资.成绩等等这样的数据就可以用int类型,有正整数.负整数和0,浮点型的也就是 ...
- [STM32F103]PWM输入捕获配置
l 初始化定时器和通道对应IO的时钟. l 初始化IO口,模式为输入: GPIO_Init(); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //PA0 ...
- TCP笔记
TCP必须是双工通讯 这种通讯方式提高通道利用率,相对于等待确认传输.
- 关于Jupyter Notebook快捷操作
Jupyter Notebook 的快捷键 Jupyter Notebook 有两种键盘输入模式.编辑模式,允许你往单元中键入代码或文本:这时的单元框线是绿色的.命令模式,键盘输入运行程序命令:这时的 ...
- Shiro的认证和权限控制
权限控制的方式 从类别上分,有两大类: - 认证:你是谁?–识别用户身份. - 授权:你能做什么?–限制用户使用的功能. 权限的控制级别 从控制级别(模型)上分: - URL级别-粗粒度 - 方法级别 ...
- Oracle表空间不足;查询表空间使用率(unable to extend lob segment SYS_LOB0000076749C00006$$ by 8192 in tablespace USERS)
查询表空间对应地址 *),) total_space from dba_data_files order by tablespace_name; //方案一:修改表空间大小(32000可改为想要的数值 ...
- 使用K-means进行聚类,用calinski_harabaz_score评价聚类效果
代码如下: """ 下面的方法是用kmeans方法进行聚类,用calinski_harabaz_score方法评价聚类效果的好坏 大概是类间距除以类内距,因此这个值越大越 ...
- xpath 笔记
from lxml import etree info = f.read() # requests.get().text # print(info) selector=etree.HTML(info ...