By picture that is displayed in Jupyter notebook isn't shown when running the same code in IDE?
I was trying to run code from an online tutorial on my local machine by copying code from Jupiter notebook to my IDE (pycharm).

This part

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from PIL import Image
from torchvision import transforms
import matplotlib.pyplot as plt

pig_img = Image.open("pig.jpg")
preprocess = transforms.Compose([
   transforms.Resize(224),
   transforms.ToTensor(),
])
pig_tensor = preprocess(pig_img)[None,:,:,:]

plt.imshow(pig_tensor[0].numpy().transpose(1,2,0))


While Jupiter notebook shows the imagine - I cannot get it displayed when running in terminal or IDE.

Any ideas why?

Thank you

You need to call .show() explicitly to show the image in terminal i.e.
Add this to the end of the code
plt.show()

From the documentation:

Display a figure. When running in ipython with its pylab mode, display all figures and return to the ipython prompt.
In non-interactive mode, display all figures and block until the figures have been closed; in interactive mode it has no effect unless figures were created prior to a change from non-interactive to interactive mode (not recommended). In that case it displays the figures but does not block.

