Issue
I have a bunch of images in "test" folder and I have a python code in a file to display those images. Here is the code
import torch
from IPython.display import Image, clear_output
import matplotlib
import glob
import PIL
from IPython.display import Image, display
from io import BytesIO
print("hi")
for imageName in glob.glob('test/images/*.jpg'): #assuming JPG
print("in \n")
display(Image(filename=imageName)) #displaying successfully in colab
print("out")
print("\n")
and here is the output when I ran the python file in ubuntu terminal.
I have no other tab opened to display image the image. I tried other answers in stack overflow but didn't work. However, the images are visible in colab's output.
Solution
You are running in a terminal, terminals can only display text.
Thus display(Image(...))
cannot display your image.
display
and Image
are really IPython/Jupyter centric utilities that cannot completely function when using purely Python.
If you want to show images when running in a terminal you will need to use something like pillow or matplotlib and ask them to open a new window with the image, and depending on how you do it, you may need to close the window for the program to keep executing.
You can also locally run jupyter notebook
(or, jupyter lab
) to open a web interface that should support images.
Answered By - Matt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.