tensorflow / models

Models and examples built with TensorFlow
Other
77.05k stars 45.77k forks source link

Missing images at the end of object_detection_tutorial.ipynb #5851

Closed Jooseba closed 4 years ago

Jooseba commented 5 years ago

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

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.

pkulzc commented 5 years ago

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

JerryZhuzq commented 5 years ago

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 commented 5 years ago

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

geek101 commented 5 years ago

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?.

CrazyHrodgar commented 5 years ago

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

custa commented 5 years ago

@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 .

zharmand commented 5 years ago

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?

Stallians commented 5 years ago

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.

custa commented 5 years ago

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.

wadekarg commented 5 years ago

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.

jmcuadra2 commented 5 years ago

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.

MattWaller commented 5 years ago

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

Worked for me! Thanks!

Marwen-Bhj commented 4 years ago

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.

Clayton-Klemm commented 4 years ago

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

aish-where-ya commented 4 years ago

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 commented 4 years ago

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?

Smellegg commented 4 years ago

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?

elSerrgio commented 4 years ago

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
koayst commented 4 years ago

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.

google-ml-butler[bot] commented 4 years ago

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] commented 4 years ago

Closing as stale. Please reopen if you'd like to work on this further.

ankhanh-vni commented 2 years ago

Hi i am running into the same issues with the tutorials on https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/auto_examples/plot_object_detection_saved_model.html#sphx-glr-auto-examples-plot-object-detection-saved-model-py

I have tried the methods mentioned but nothing worked