Need help in solving a Runtime error while creating a databunch

I am trying to create a GAN based on the notebook “lesson7-superres-gan” of Part 1(2019). I am using the dataset here https://www.kaggle.com/rounakbanik/pokemon.
While creating data for pretraining the critic I am facing the following error –

RuntimeError: number of dims don't match in permute

I have the following folder structure-
Main folder
* --crappy*
* --images*

The code which is creating the data is -->

def get_databunch(image_source, path_lr, batch_size, image_size):
    data = image_source.label_empty().transform(size=image_size,tfm_y=True).databunch   (bs=batch_size).normalize(imagenet_stats, do_y=True)
data.c = 3
return data

Data -->

data = get_databunch(image_source, path_lr, batch_size, image_size)

The line for code which throws the error–>
data.show_batch(2)

The stack trace –
–>
RuntimeError Traceback (most recent call last)
in ()
----> 1 data.show_batch()

C:\ProgramData\Anaconda3\lib\site-packages\fastai\basic_data.py in show_batch(self, rows, ds_type, reverse, **kwargs)
192 ys = [self.train_ds.y.reconstruct(grab_idx(y, i), x=x) for i,x in enumerate(xs)]
193 else : ys = [self.train_ds.y.reconstruct(grab_idx(y, i)) for i in range(n_items)]
–> 194 self.train_ds.x.show_xys(xs, ys, **kwargs)
195
196 def export(self, file:PathLikeOrBinaryStream=‘export.pkl’):

C:\ProgramData\Anaconda3\lib\site-packages\fastai\vision\data.py in show_xys(self, xs, ys, imgsize, figsize, **kwargs)
302 rows = int(np.ceil(math.sqrt(len(xs))))
303 axs = subplots(rows, rows, imgsize=imgsize, figsize=figsize)
–> 304 for x,y,ax in zip(xs, ys, axs.flatten()): x.show(ax=ax, y=y, **kwargs)
305 for ax in axs.flatten()[len(xs):]: ax.axis(‘off’)
306 plt.tight_layout()

C:\ProgramData\Anaconda3\lib\site-packages\fastai\vision\image.py in show(self, ax, figsize, title, hide_axis, cmap, y, **kwargs)
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)
223

C:\ProgramData\Anaconda3\lib\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)

C:\ProgramData\Anaconda3\lib\site-packages\fastai\vision\image.py in show_image(img, ax, figsize, hide_axis, cmap, alpha, **kwargs)
428 “Display Image in notebook.”
429 if ax is None: fig,ax = plt.subplots(figsize=figsize)
–> 430 ax.imshow(image2np(img.data), cmap=cmap, alpha=alpha, **kwargs)
431 if hide_axis: ax.axis(‘off’)
432 return ax

C:\ProgramData\Anaconda3\lib\site-packages\fastai\vision\image.py in image2np(image)
22 def image2np(image:Tensor)->np.ndarray:
23 “Convert from torch style image to numpy/matplotlib style.”
—> 24 res = image.cpu().permute(1,2,0).numpy()
25 return res[…,0] if res.shape[2]==1 else res
26

RuntimeError: number of dims don’t match in permute

Not very sure, but did you check the number of channels of input and target?

Hey, thanks for the reply. But I have already resolved the issue. It seemed to me that the path from where I was fetching my data was incorrect.

I just forgot to update this post .