Are PNG files supported in data.show_batch / interp_plot losses etc?

(Less ) #1

I’m doing work on a solar panel system and while I’m able to do the training, I can’t access the data bunch plotting or top losses plotting, etc.
I get this:

~/anaconda3/lib/python3.7/site-packages/matplotlib/image.py in set_data(self, A)
676 not np.can_cast(self._A.dtype, float, “same_kind”)):
677 raise TypeError("Image data of dtype {} cannot be converted to "
–> 678 “float”.format(self._A.dtype))
679
680 if not (self._A.ndim == 2

TypeError: Image data of dtype object cannot be converted to float

FastAI: ‘1.0.58.dev0’

PyTorch: 1.2.0

I wanted to pull the gradCAM images to look at how it’s ‘seeing’ things but right now I can train but can’t see anything.

Thanks for any ideas!

1 Like

(Less ) #2

full trace:


TypeError Traceback (most recent call last)
in
3 x.show(ax, y=y)
4
----> 5 plot_multi(_plot, 3, 3, figsize=(8,8))

~/anaconda3/lib/python3.7/site-packages/fastai/vision/image.py in plot_multi(func, r, c, figsize)
614 axes = plt.subplots(r, c, figsize=figsize)[1]
615 for i in range®:
–> 616 for j in range©: func(i,j,axes[i,j])
617
618 def show_multi(func:Callable[[int,int],Image], r:int=1, c:int=1, figsize:Tuple=(9,9)):

in _plot(i, j, ax)
1 def _plot(i,j,ax):
2 x,y = data.train_ds[3]
----> 3 x.show(ax, y=y)
4
5 plot_multi(_plot, 3, 3, figsize=(8,8))

~/anaconda3/lib/python3.7/site-packages/fastai/vision/image.py in show(self, ax, figsize, title, hide_axis, cmap, y, **kwargs)
218 "Show image on ax with title, using cmap if single-channel, overlaid with optional y"
219 cmap = ifnone(cmap, defaults.cmap)
–> 220 ax = show_image(self, ax=ax, hide_axis=hide_axis, cmap=cmap, figsize=figsize)
221 if y is not None: y.show(ax=ax, **kwargs)
222 if title is not None: ax.set_title(title)

~/anaconda3/lib/python3.7/site-packages/fastai/vision/image.py in show_image(img, ax, figsize, hide_axis, cmap, alpha, **kwargs)
434 if ax is None: fig,ax = plt.subplots(figsize=figsize)
435 xtr = dict(cmap=cmap, alpha=alpha, **kwargs)
–> 436 ax.imshow(image2np(img.data), **xtr) if (hasattr(img, ‘cpu’)) else ax.imshow(img, **xtr)
437 if hide_axis: ax.axis(‘off’)
438 return ax

~/anaconda3/lib/python3.7/site-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1587 def inner(ax, *args, data=None, **kwargs):
1588 if data is None:
-> 1589 return func(ax, *map(sanitize_sequence, args), **kwargs)
1590
1591 bound = new_sig.bind(ax, *args, **kwargs)

~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
–> 369 return func(*args, **kwargs)
370
371 return wrapper

~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
–> 369 return func(*args, **kwargs)
370
371 return wrapper

~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5658 resample=resample, **kwargs)
5659
-> 5660 im.set_data(X)
5661 im.set_alpha(alpha)
5662 if im.get_clip_path() is None:

~/anaconda3/lib/python3.7/site-packages/matplotlib/image.py in set_data(self, A)
676 not np.can_cast(self._A.dtype, float, “same_kind”)):
677 raise TypeError("Image data of dtype {} cannot be converted to "
–> 678 “float”.format(self._A.dtype))
679
680 if not (self._A.ndim == 2

TypeError: Image data of dtype object cannot be converted to float

0 Likes

#3

Hi LessW2020 hope you’re not as swamped as you have been.

I can’t fix your problem but I did a quick look on Stack and noticed the error is not uncommon, maybe something in this or other posts will help stimulate ideas to assist you in solving this problem.

I am currently still working on my apps for lesssons 3-7 and have a few png datasets so I would like to see how you resolve this problem.

Hope this helps

mrfablulous :smiley::smiley:

1 Like

(rares t) #4

Hello @LessW2020, have you found any solution to this problem? Thank you

0 Likes

(Pavel Rybnicek) #5

I get the
TypeError: Image data of dtype object cannot be converted to float
error when I mess with my libraries versions. Creating a new fresh conda environment always helps.

0 Likes