karolzak / ipyplot

IPyPlot is a small python package offering fast and efficient plotting of images inside Python Notebooks. It's using IPython with HTML for faster, richer and more interactive way of displaying big numbers of images.
MIT License
415 stars 41 forks source link

Google Colab Zoom in/out not working. #32

Closed rickkk856 closed 3 years ago

rickkk856 commented 3 years ago

I am plotting an image grid of files from my google drive. However, when I double click an image to enlage (zoom) it, the Ipyplot tries to open it on https://localhost:8080/#ipyplot-content-div-gxxhDYw6uZPAFysCBXxHRa-KQknA24YyNKi4us9tmHekN but this page does not exist, then If I want to see the images, I have to run the cell again...

images_pil = [Image.open(image) for image in images]
ipyplot.plot_images(images_pil, labels, img_width=256, max_images=10, force_b64=True)

I even tried to solve it by making a refresh button like this:

import ipywidgets as widgets
from IPython.display import display
button = widgets.Button(description="Refresh Images")
output = widgets.Output()

def on_button_clicked(b):
  # Display the message within the output widget.
  with output:
    ipyplot.plot_images(images_pil, labels, img_width=256, max_images=10, force_b64=True)

button.on_click(on_button_clicked)
display(button, output)

Even though, after the link is open, the button disappears 😢

rickkk856 commented 3 years ago

Nevermind, I could solve it by using an earlier version of the package:

Just use !pip install ipyplot==1.0.1 version

then remove the force_b64=True from ipyplot.plot_images(images_pil, labels, img_width=256, max_images=10)

PS: if you right click the image and go to "open in new tab" you can see the image in its full size.