models icon indicating copy to clipboard operation
models copied to clipboard

Missing images at the end of object_detection_tutorial.ipynb

Open Jooseba opened this issue 7 years ago • 22 comments

So I have been straight now trying to install tensorflow with object_detection about 20h for two computers without any succsess. I don't get any errors but I haven't seen the dog and beach picture at all. Any suggestions why it is not working? Anyone else has this problem?

System informationg

  • Tenso\models:
  • Win 10 pro 64-bit both computers:
  • This site:
  • 1.12 GPU:
  • CUDA/cuDNN version 9/7:
  • GTX970 4GB and GTX1060 6GB mobile:

Describe the problem

-I can start the object_detection_tutorial.ipynb, but I don't get the test images neither any error messages. It goes well to end of the script but the images are missing.

Source code / logs

-orginal code, straight from here.

Jooseba avatar Dec 02 '18 16:12 Jooseba

Could you share the whatever printed in your terminal? You should be able to see something there.

pkulzc avatar Dec 02 '18 16:12 pkulzc

I had the same problem. And the printed information is in the following: from utils import label_map_util

from utils import visualization_utils as vis_util C:\pycharm\files\Object Detection\models\research\object_detection\utils\visualization_utils.py:27: UserWarning: This call to matplotlib.use() has no effect because the backend has already been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time.

The backend was originally set to 'module://ipykernel.pylab.backend_inline' by the following code: File "c:\users\asus\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\asus\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel_launcher.py", line 16, in app.launch_new_instance() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\kernelapp.py", line 505, in start self.io_loop.start() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\platform\asyncio.py", line 132, in start self.asyncio_loop.run_forever() File "c:\users\asus\appdata\local\programs\python\python36\lib\asyncio\base_events.py", line 421, in run_forever self._run_once() File "c:\users\asus\appdata\local\programs\python\python36\lib\asyncio\base_events.py", line 1431, in _run_once handle._run() File "c:\users\asus\appdata\local\programs\python\python36\lib\asyncio\events.py", line 145, in _run self._callback(*self._args) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\ioloop.py", line 758, in _run_callback ret = callback() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\stack_context.py", line 300, in null_wrapper return fn(*args, **kwargs) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1233, in inner self.run() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1147, in run yielded = self.gen.send(value) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\kernelbase.py", line 370, in dispatch_queue yield self.process_one() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 346, in wrapper runner = Runner(result, future, yielded) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1080, in init self.run() File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1147, in run yielded = self.gen.send(value) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\kernelbase.py", line 357, in process_one yield gen.maybe_future(dispatch(*args)) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\kernelbase.py", line 267, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\kernelbase.py", line 534, in execute_request user_expressions, allow_stdin, File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\ipkernel.py", line 294, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\ipykernel\zmqshell.py", line 536, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2819, in run_cell raw_cell, store_history, silent, shell_futures) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2845, in run_cell return runner(coro) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\async_helpers.py", line 67, in pseudo_sync_runner coro.send(None) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3020, in run_cell_async interactivity=interactivity, compiler=compiler, result=result) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3191, in run_ast_nodes if (yield from self.run_code(code, result)): File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 2, in get_ipython().run_line_magic('matplotlib', 'inline') File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2287, in run_line_magic result = fn(*args,**kwargs) File "", line 2, in matplotlib File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\magic.py", line 187, in call = lambda f, *a, **k: f(*a, **k) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\magics\pylab.py", line 99, in matplotlib gui, backend = self.shell.enable_matplotlib(args.gui) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3355, in enable_matplotlib pt.activate_matplotlib(backend) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\IPython\core\pylabtools.py", line 314, in activate_matplotlib matplotlib.pyplot.switch_backend(backend) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\matplotlib\pyplot.py", line 231, in switch_backend matplotlib.use(newbackend, warn=False, force=True) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\matplotlib_init.py", line 1410, in use reload(sys.modules['matplotlib.backends']) File "c:\users\asus\appdata\local\programs\python\python36\lib\importlib_init.py", line 166, in reload _bootstrap.exec(spec, module) File "c:\users\asus\appdata\local\programs\python\python36\lib\site-packages\matplotlib\backends_init.py", line 16, in line for line in traceback.format_stack()

import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements

JerryZhuzq avatar Dec 04 '18 04:12 JerryZhuzq

I know what was wrong. from matplotlib import pyplot as plt should be changed into import matplotlib.pyplot as plt

JerryZhuzq avatar Dec 04 '18 04:12 JerryZhuzq

The problem here seems to be importing of matplotlib in visualization_utils.py. Perhaps the APIs should simply take argument 'plt' defined by the notebook/caller.

Commenting out the matplotlib imports in the .py and keeping them in the notebook does draw. Not sure if there is any other way to solve this?.

geek101 avatar Jan 27 '19 19:01 geek101

Appartently there is problem with the models used. Use this line MODEL_NAME = 'faster_rcnn_resnet101_coco_2017_11_08' in the section "Model preparation". As for the matplotlib issues, it works fine for me without any changes. Hope this will help.

os: windows 10 python: python 3.6.8 | Anaconda 4.6.7 tensorflow gpu 1.12

CrazyHrodgar avatar Mar 09 '19 07:03 CrazyHrodgar

@Jooseba Same issue, but when I execute the notebook again, then two images appear.

It seem matplotlib 3.0.2 cause the problem, try downgrade to 3.0.1 .

custa avatar Mar 13 '19 17:03 custa

I know what was wrong. from matplotlib import pyplot as plt should be changed into import matplotlib.pyplot as plt @JerryZhuzq
It works for me too! But why? What's the difference between the two sentences?

zharmand avatar May 09 '19 15:05 zharmand

I know what was wrong. from matplotlib import pyplot as plt should be changed into import matplotlib.pyplot as plt @JerryZhuzq It works for me too! But why? What's the difference between the two sentences?

Does not work for me.

Stallians avatar Jun 06 '19 10:06 Stallians

I know what was wrong. from matplotlib import pyplot as plt should be changed into import matplotlib.pyplot as plt @JerryZhuzq It works for me too! But why? What's the difference between the two sentences?

Does not work for me.

Try my solution above.

custa avatar Jul 15 '19 06:07 custa

I had same issue and I was getting this issue for both commands

from matplotlib import pyplot as plt import matplotlib.pyplot as plt but when it was not working I changed it to another command. it is for sure that one of it will work. so both of the commands are correct.

wadekarg avatar Aug 09 '19 20:08 wadekarg

I have added in the images display cell %matplotlib inline before plt.figure(figsize=IMAGE_SIZE). vis_util.visualize_boxes_and_labels_on_image_array() is called before plt.figure() and it changes to Agg backend, visualization_utils.py line 29: import matplotlib; matplotlib.use('Agg'). I have also added at the end of the cell plt.show() to show all images. I'm using matplotlib 3.0.2.

jmcuadra2 avatar Sep 21 '19 18:09 jmcuadra2

I know what was wrong. from matplotlib import pyplot as plt should be changed into import matplotlib.pyplot as plt

Worked for me! Thanks!

MattWaller avatar Sep 30 '19 07:09 MattWaller

I downgraded matplotlib from 3.1.1 to 3.0.1, I commented the two lines in the visualization_utils.py, tried another model, used the %matplotlib inline within the visulaization_utils.py , changed the import maptlolib.pyplot line and nothing seems to work.

Marwen-Bhj avatar Nov 28 '19 13:11 Marwen-Bhj

Also not working for me after first using the latest version of protobuf. then downgraded it to v3.4.0

then I tried changing matplotlib.pyplot import.

then I tried downgrading matplotlib to version 3.0.1

still not working. console reads: [W 14:13:00.409 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200112141245 (::1) 14.00ms referer=http://localhost:8888/notebooks/object_detection/object_detection_tutorial.ipynb [I 14:13:01.299 NotebookApp] Kernel started: 31817f07-81f1-470a-a040-65e8b966f085 [I 14:15:02.135 NotebookApp] Saving file at /object_detection/object_detection_tutorial.ipynb

Clayton-Klemm avatar Jan 12 '20 20:01 Clayton-Klemm

Also not working for me after first using the latest version of protobuf. then downgraded it to v3.4.0

then I tried changing matplotlib.pyplot import.

then I tried downgrading matplotlib to version 3.0.1

still not working. console reads: [W 14:13:00.409 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200112141245 (::1) 14.00ms referer=http://localhost:8888/notebooks/object_detection/object_detection_tutorial.ipynb [I 14:13:01.299 NotebookApp] Kernel started: 31817f07-81f1-470a-a040-65e8b966f085 [I 14:15:02.135 NotebookApp] Saving file at /object_detection/object_detection_tutorial.ipynb

I am facing the same problem. Did you manage to find a workaround?

aish-where-ya avatar Mar 16 '20 15:03 aish-where-ya

I downgraded matplotlib from 3.1.1 to 3.0.1, I commented the two lines in the visualization_utils.py, tried another model, used the %matplotlib inline within the visulaization_utils.py , changed the import maptlolib.pyplot line and nothing seems to work.

Hello. Did you manage to get your model to work?

aish-where-ya avatar Mar 16 '20 15:03 aish-where-ya

Hi all, Glad Im not the only one in this boat.

Same issue, no image displayed at the end, but no errors showing either. I commented out the matplotlib in utilit/visu.py and nothing changes if I do or dont comment it out.

I added %matplotlib inline before the output but no luck. Im on matplotlib 3.2.1 and unable to install version 3.0.1

Anyone any insights?

Smellegg avatar Apr 04 '20 15:04 Smellegg

Try to comment this two lines in research/object_detection/utils/visualization_utils.py as described here: https://github.com/tensorflow/models/issues/6684. Worked for me on different pcs and without downgrading.

#import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements
#import matplotlib.pyplot as plt # pylint: disable=g-import-not-at-top

elSerrgio avatar Jul 07 '20 15:07 elSerrgio

After commenting out the 2 lines as shown below:

#import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements #import matplotlib.pyplot as plt # pylint: disable=g-import-not-at-top

Need to perform the below as indicated in => https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html

#From within TensorFlow/models/research/ cp object_detection/packages/tf2/setup.py . python -m pip install .

then it worked for me i.e the 2 pictures showed up.

koayst avatar Jul 31 '20 03:07 koayst

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Sep 11 '20 15:09 google-ml-butler[bot]