完美解决丨RuntimeError: create_session() called before __init__().

简介: 完美解决丨RuntimeError: create_session() called before __init__().

错误:

import sys

sys.path.append('/home/pi/ssd-detect')

import ssd_detect

ssd_detect.detect('/home/pi/ssd-detect/test.jpg')

报错如下:

Traceback (most recent call last):

File "test.py", line 6, in <module

ssd_detect.detect('/home/pi/ssd-detect/test.jpg')

File "/home/pi/ssd-detect/ssd_detect.py", line 31, in detect

output_dict = run_inference_for_single_image(image_np, detection_graph)

File "/home/pi/ssd-detect/ssd_detect.py", line 15, in run_inference_for_single_image

with tf.Session() as sess:

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1551, in enter

return self._default_session().enter()

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 536, in _default_session

self._session_impl_fn)

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 633, in _create_session

return self._session_factory.create_session()

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 662, in create_session

raise RuntimeError('create_session() called before init().')

RuntimeError: create_session() called before init().

解决办法:

链接:https://www.jianshu.com/p/6c8e611d73b7

原因分析:

根据错误的描述,也就是说调用了 sess.run() 这个函数之前没有初始化 sess ,这样就会报错。

这个错误是因为 sess.run() 这个函数是在 sess 被初始化之后才能被调用。


相关文章
|
9月前
|
Serverless
attempt to delete a method
attempt to delete a method
127 1
|
28天前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
12 1
|
5月前
Failed to execute script ‘xxx‘ due to unhandled exception:No module named ‘ctypes‘
Failed to execute script ‘xxx‘ due to unhandled exception:No module named ‘ctypes‘
136 0
|
8月前
|
网络安全 Docker 容器
failed to create network error response from daemon filed to setup ip tables问题
failed to create network error response from daemon filed to setup ip tables问题
120 0
|
8月前
|
JSON 数据格式
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
成功解决 global init errTypeError:Right-hand side of 'instanceof' is not callable
BeanFactory not initialized or already closed - call 'refresh' before access
BeanFactory not initialized or already closed - call 'refresh' before access
175 0
|
关系型数据库 MySQL Java
解决方案 --Failed to initialize JPA EntityManagerFactory: Unable to create requested service
解决方案 --Failed to initialize JPA EntityManagerFactory: Unable to create requested service
解决方案 --Failed to initialize JPA EntityManagerFactory: Unable to create requested service
OPA 11 - how is check called in my iClickTheCreateButton
Created by Wang, Jerry, last modified on Nov 08, 2015
124 0
OPA 11 - how is check called in my iClickTheCreateButton

热门文章

最新文章