2
votes

I encountered the following error when I try to test the object detection 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

The following error appears after running the model_builder_test.py

.W0220 03:22:35.097244 140099951081344 deprecation.py:323] From /content/models/research/object_detection/anchor_generators/grid_anchor_generator.py:59: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. .. WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see: * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md * https://github.com/tensorflow/addons If you depend on functionality not listed there, please file an issue.

..................s ---------------------------------------------------------------------- Ran 22 tests in 0.203s

OK (skipped=1) --------------------------------------------------------------------------- AttributeError Traceback (most recent call 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

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

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in run_line_magic(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 return result 2083

in run(self, parameter_s, runner, file_finder)

/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py in (f, *a, **k) 186 # but it's overkill for just that one bit of state. 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 in run(self, parameter_s, runner, file_finder) 740 else: 741 # regular execution --> 742 run() 743 744 if 'i' in opts:

/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py in run() 726 def run(): 727 runner(filename, prog_ns, prog_ns, --> 728 exit_ignore=exit_ignore) 729 730 if 't' in opts:

/usr/local/lib/python3.6/dist-packages/IPython/core/pylabtools.py in mpl_execfile(fname, *where, **kw) 175 matplotlib.interactive(is_interactive) 176 # make rendering call now, if the user tried to do it --> 177 if plt.draw_if_interactive.called: 178 plt.draw() 179 plt.draw_if_interactive.called = False

AttributeError: 'function' object has no attribute 'called'

1
Does this not come with a jupyter notebook?gorilla bull
I am using the jupyter notebook on colab...not sure what 'this' you are referring to?Water Chan

1 Answers

0
votes

This is how I overcame the issue:

  1. install prompt-toolkit to the version 1.0.15, as explained in the link below https://github.com/jupyter/jupyter_console/issues/158

  2. restart the runtime to activate the package

  3. use '!python' instead of '%run'