Show_results with bs=1 give 'too many indices for array' error

When I use CycleGan from coursev3 with my own dataset (5k images for each class),
show_results works with bs=4 but not with bs=1
I can fit a model without error but can’t use show_results afterward.

I got this error while showing results.
learn.show_results(ds_type=DatasetType.Train)

My data loading is the same except not transforming as all my images are 256,256 size and I use bs = 1

data = None
data = (ImageTupleList.from_folders(path, 'trainA', 'trainB')
                      .split_none()
                      .label_empty()
                      .transform(get_transforms())
                      .databunch(bs=1))

And show_xyzs function:

 def show_xyzs(self, xs, ys, zs, figsize:Tuple[int,int]=None, **kwargs):
        """Show `xs` (inputs), `ys` (targets) and `zs` (predictions) on a figure of `figsize`.
        `kwargs` are passed to the show method."""
        figsize = ifnone(figsize, (12,3*len(xs)))
        fig,axs = plt.subplots(len(xs), 2, figsize=figsize)
        fig.suptitle('Ground truth / Predictions', weight='bold', size=14)
        for i,(x,z) in enumerate(zip(xs,zs)):
            x.to_one().show(ax=axs[i,0], **kwargs)
            z.to_one().show(ax=axs[i,1], **kwargs)
1 Like

I have a similar error “too many indices for array”


any idea?

Can it be the .view(-1) method in Pytorch that we should us?


I checked the Size with .size function and then assign that array and it works, but not sure why it shows in this way. like only 3 “columns”.

Probably because it is a .jpg and not .png