Icevision: Error in Inference tutorial for `show_preds()`

Created on 11 Feb 2021  路  3Comments  路  Source: airctic/icevision

馃悰 Bug

Describe the bug
I'm facing a bug with the show_preds() function when following the Inference tutorial notebook on Google Colab. Everything was ok until this last part.

Screenshots

# Show preds by grabbing the images from `samples`
imgs = [sample["img"] for sample in samples]
show_preds(
    samples=imgs,
    preds=preds,
    class_map=class_map,
    denormalize_fn=denormalize_imagenet,
    show=True,
)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-c218e6fc2293> in <module>()
      6     class_map=class_map,
      7     denormalize_fn=denormalize_imagenet,
----> 8     show=True,
      9 )

4 frames
/usr/local/lib/python3.6/dist-packages/icevision/visualize/show_data.py in show_preds(samples, preds, class_map, denormalize_fn, display_label, display_bbox, display_mask, ncols, figsize, show, annotations)
    203         ]
    204         plot_grid(
--> 205             partials, ncols=ncols, figsize=figsize, show=show, annotations=annotations
    206         )

/usr/local/lib/python3.6/dist-packages/icevision/utils/imageio.py in plot_grid(fs, ncols, figsize, show, **kwargs)
     31     figsize = figsize or (12 * ncols, 12 * nrows)
     32 
---> 33     fig, axs = plt.subplots(nrows=nrows, ncols=ncols, figsize=figsize, **kwargs)
     34     axs = np.asarray(axs)
     35     for f, ax in zip(fs, axs.flatten()):

/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py in subplots(nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw)
   1175 
   1176     """
-> 1177     fig = figure(**fig_kw)
   1178     axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
   1179                        squeeze=squeeze, subplot_kw=subplot_kw,

/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
    544                                         frameon=frameon,
    545                                         FigureClass=FigureClass,
--> 546                                         **kwargs)
    547 
    548         if figLabel:

/usr/local/lib/python3.6/dist-packages/matplotlib/backend_bases.py in new_figure_manager(cls, num, *args, **kwargs)
   3355         from matplotlib.figure import Figure
   3356         fig_cls = kwargs.pop('FigureClass', Figure)
-> 3357         fig = fig_cls(*args, **kwargs)
   3358         return cls.new_figure_manager_given_figure(num, fig)
   3359 

TypeError: __init__() got an unexpected keyword argument 'annotations'

Desktop (please complete the following information):

  • Google Colab
bug

Most helpful comment

The "Inference" tutorial seems to work fine if you switch to the pre-release 0.6.0b1.

Just use:

!pip install icevision[all]==0.6.0b1 icedata

Although, afterwards I switched back to an earlier version instead (0.5.1), since the pre-release seems to break the "Getting Started" example, such that we can do both learning the model and inference on the same version of IceVision.

I hope it helps anyone who's starting with IceVision and running into the same issues 馃槃 Cheers!

All 3 comments

The "Inference" tutorial seems to work fine if you switch to the pre-release 0.6.0b1.

Just use:

!pip install icevision[all]==0.6.0b1 icedata

Although, afterwards I switched back to an earlier version instead (0.5.1), since the pre-release seems to break the "Getting Started" example, such that we can do both learning the model and inference on the same version of IceVision.

I hope it helps anyone who's starting with IceVision and running into the same issues 馃槃 Cheers!

As @Addono mentioned the problem was introduced by changing the module icevision/visualize/show_data.py between version 0.5.2 and 0.6.0b1.
This can be seen by comparing the two commit tags: https://github.com/airctic/icevision/compare/0.5.2...0.6.0b1#diff-7f113801b36cb9dda3badc10bea4105ea5af712c9e2c39f5b510239204af5840

As a temporary solution I use version 0.5.2 and re-implement in my own code show_preds() exactly like in version 0.6.0b1: https://gist.github.com/markus-hinsche/98812edfede67e907034b9b7d5d1f982

This is fixed on master and will be working on our next release 0.7.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lgvaz picture lgvaz  路  4Comments

lgvaz picture lgvaz  路  5Comments

lgvaz picture lgvaz  路  5Comments

lgvaz picture lgvaz  路  3Comments

RibenaMapleSyrup picture RibenaMapleSyrup  路  3Comments