Google Colab - tensowflow对象检测api - 'function'对象没有属性'called'

问题描述 投票:1回答:1

当我尝试测试对象检测api model_builder_test.py时遇到以下错误。

!apt-get install -y -qq protobuf-compiler python-pil python-lxml
!git clone --quiet https://github.com/tensorflow/models.git

import os
os.chdir('models/research')

!protoc object_detection/protos/*.proto --python_out=.
import sys
sys.path.append('/content/models/research/slim')

%run object_detection/builders/model_builder_test.py

运行model_builder_test.py后出现以下错误

.W0220 03:22:35.097244 140099951081344 deprecation.py:323]来自/content/models/research/object_detection/anchor_generators/grid_anchor_generator.py:59:to_float(来自tensorflow.python.ops.math_ops)已弃用,将被删除未来的版本。更新说明:改用tf.cast。 ..警告:TensorFlow contrib模块不包含在TensorFlow 2.0中。有关详细信息,请参阅:* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md * https://github.com/tensorflow/addons如果您依赖于此处未列出的功能,请提出问题。

.................. s ------------------------------- ---------------------------------------在0.203s进行22次测试

确定(跳过= 1)-------------------------------------------- ------------------------------- AttributeError Traceback(最近一次调用last)in()----> 1 get_ipython( ).magic('run object_detection / builders / model_builder_test.py')

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in magic(self,arg_s)2158 magic_name,_,magic_arg_s = arg_s.partition('')2159 magic_name = magic_name.lstrip( prefilter.ESC_MAGIC) - > 2160 return self.run_line_magic(magic_name,magic_arg_s)2161 2162

-------------------------------------------------------------------------

run_line_magic中的/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py(self,magic_name,line)2079 kwargs ['local_ns'] = sys._getframe(stack_depth).f_locals 2080 with self.builtin_trap: - > 2081 result = fn(* args,** kwargs)2082返回结果2083

在运行中(self,parameter_s,runner,file_finder)

/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py in(f,* a,** k)186#但是只有那一位状态才有点过分。 187 def magic_deco(arg): - > 188 call = lambda f,* a,** k:f(* a,** k)189 190 if callable(arg):

运行中的/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py(self,parameter_s,runner,file_finder)740 else:741#regular execution - > 742 run()743 744如果选择'i':

run()中的/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py 726 def run():727 runner(filename,prog_ns,prog_ns, - > 728 exit_ignore = exit_ignore )如果选择't',则为729 730:

mpl_execfile中的/usr/local/lib/python3.6/dist-packages/IPython/core/pylabtools.py(fname,* where,** kw)175 matplotlib.interactive(is_interactive)176#现在进行渲染调用,如果用户试图这样做 - > 177如果plt.draw_if_interactive.called:178 plt.draw()179 plt.draw_if_interactive.called = False

AttributeError:'function'对象没有属性'called'

python-3.x tensorflow matplotlib google-colaboratory object-detection-api
1个回答
0
投票

这就是我克服这个问题的方法:

  1. 将prompt-toolkit安装到版本1.0.15,如https://github.com/jupyter/jupyter_console/issues/158下面的链接所述
  2. 重新启动运行时以激活程序包
  3. 用'!python'代替'%run'
© www.soinside.com 2019 - 2024. All rights reserved.