【问题标题】:Google Colab - tensowflow object detection api - 'function' object has no attribute 'called'Google Colab - tensowflow 对象检测 api - “函数”对象没有“调用”属性
【发布时间】:2019-07-13 16:16:55
【问题描述】:

我在尝试测试对象检测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.203 秒内运行 22 次测试

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

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py 在魔法(自我,arg_s)2158魔法名称,_,magic_arg_s = arg_s.partition('') 2159 魔法名称 = magic_name.lstrip(前置过滤器.ESC_MAGIC) -> 2160 返回 self.run_line_magic(magic_name, magic_arg_s) 2161 2162

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

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

in run(self, parameter_s, runner, file_finder)

/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py 在 (f, *a, **k) 186 # 但对于那一点状态来说就有点过分了。 第187章 --> 188 调用 = lambda f, *a, **k: f(*a, **k) 189 190 如果可调用(arg):

/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py 在运行中(self,parameter_s,runner,file_finder) 740 其他: 第741章 --> 742 运行() 743 第744章

/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py 在运行() 第726章 727亚军(文件名,prog_ns,prog_ns, --> 728 退出_忽略=退出_忽略) 729 730 if 't' in opts:

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

AttributeError:“函数”对象没有“调用”属性

【问题讨论】:

  • 这个不是jupyter notebook自带的吗?
  • 我在 colab 上使用 jupyter notebook...不确定您指的是什么“this”?

标签: python-3.x tensorflow matplotlib google-colaboratory object-detection-api


【解决方案1】:

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

  1. 将 prompt-toolkit 安装到 1.0.15 版本,如以下链接中所述 https://github.com/jupyter/jupyter_console/issues/158

  2. 重启运行时激活包

  3. 使用 '!python' 而不是 '%run'

【讨论】:

  • 它并没有解决我的问题。我仍在寻找解决问题的方法。
  • 回溯(最近一次调用最后):文件“object_detection/builders/model_builder_test.py”,第 23 行,在 from object_detection.builders import model_builder ModuleNotFoundError: No module named 'object_detection'跨度>
  • @OsamaAdly 您需要 PYTHONPATH 环境变量。 import osos.environ['PYTHONPATH'] += ":/content/models/research:/content/models/research/slim"
  • 这解决了错误,但 matplotlib 图不再显示 :( 尝试过 ! python3 pythonscript.py!python pythonscript.py%run pythonscript.py
猜你喜欢
  • 2020-04-16
  • 2021-02-02
  • 1970-01-01
  • 2023-03-19
  • 2013-04-29
  • 2022-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多