Show_batch not displaying in pycharm

Hello :slight_smile:
I just started experimenting with fastai and I was trying to run the segmentation tutorial. However, I noticed that show_batch() does not display anything when run in pycharm while working correctly if run in a notebook. Is that an expected behaviour? is there a way to make it work also using pycharm?

In case it’s relevant I’m using fastai 2.8.1 and the code I’m running is exactly the same as the tutorials, i.e.:

from fastai.vision.all import *
path = untar_data(URLs.CAMVID_TINY)

codes = np.loadtxt(path/'codes.txt', dtype=str)

fnames = get_image_files(path/"images")

def label_func(fn): return path/"labels"/f"{fn.stem}_P{fn.suffix}"

dls = SegmentationDataLoaders.from_label_func(
path, bs=8, fnames = fnames, label_func = label_func, codes = codes
)

dls.show_batch(max_n=6)

Thanks in advance :slight_smile:

dls.show_batch() works on notebook. You will not be able to use it inside IDE’s like VScode/PyCharm.

1 Like

I see, thanks

Just to confirm, dls.show_batch() will not do anything If running the python segmentation example as a script from a terminal (regardless of IDE)?

1 Like