Plotting images using a for loop

I want to use a for loop to plot images with fastai show_image.

If I do something like in the example below, it firstly plots all the images, and then all the text, while I want the text Sample No. to be put below each image, as it should be since it is in the same iteration of a for loop.

(here, img is an image as in the first entry of a valid_ds tuple)

for sampleN in range(samples):
        show_image(img)
        print('Sample No. '+str(sampleN))

Suggestions?

1 Like

Can you do something like this:

Image.show(image, title=‘This is my title’ )

1 Like

try adding a plt.show() before the print statement

1 Like

No, indeed show_image() is a fastai function, not the one from matplotlib. But I’ll try and implement a version with .show(), thanks!

That solved my problem, thanks!

This may work too

1 Like

Awesome :slight_smile: