Skip to main content

Simple package that leverages IPython and HTML for more efficient, reach and interactive plotting of images in Jupyter Notebooks

Project description

Build PyPI - version Downloads Downloads/Month license

Share:
Twitter URL LinkedIn URL

IPyPlot is a small python package offering fast and efficient plotting of images inside Python Notebooks cells. It's using IPython with HTML for faster, richer and more interactive way of displaying big numbers of images.

Displaying big numbers of images with Python in Notebooks always was a big pain for me as I always used matplotlib for that task and never have I even considered if it can be done faster, easier or more efficiently.
Especially in one of my recent projects I had to work with a vast number of document images in a very interactive way which led me to forever rerunning notebook cells and waiting for countless seconds for matplotlib to do it's thing..
My frustration grew up to the point were I couldn't stand it anymore and started to look for other options..
Best solution I found involved using IPython package in connection with simple HTML. Using that approach I built this simple python package called IPyPlot which finally helped me cure my frustration and saved a lot of my time.

Features:

  • <input type="checkbox" checked="" disabled="" /> Easy, fast and efficient plotting of images in python within notebooks
  • <input type="checkbox" checked="" disabled="" /> Plotting functions (see examples section to learn more):
    • <input type="checkbox" checked="" disabled="" /> plot_images - simply plots all the images in a grid-like layout
    • <input type="checkbox" checked="" disabled="" /> plot_class_representations - similar to plot_images but displays only the first image for each label/class (based on provided labels collection)
    • <input type="checkbox" checked="" disabled="" /> plot_class_tabs - plots images in a grid-like manner in a separate tab for each label/class based on provided labels
  • <input type="checkbox" checked="" disabled="" /> Supported image formats:
    • <input type="checkbox" checked="" disabled="" /> Sequence of local storage URLs, e.g. [your/dir/img1.jpg]
    • <input type="checkbox" checked="" disabled="" /> Sequence of remote URLs, e.g. [http://yourimages.com/img1.jpg]
    • <input type="checkbox" checked="" disabled="" /> Sequence of PIL.Image objects
    • <input type="checkbox" checked="" disabled="" /> Sequence of images as numpy.ndarray objects
    • <input type="checkbox" checked="" disabled="" /> Supported sequence types: list, numpy.ndarray, pandas.Series
  • <input type="checkbox" checked="" disabled="" /> Misc features:
    • <input type="checkbox" checked="" disabled="" /> custom_texts param to display additional texts like confidence score or some other information for each image
    • <input type="checkbox" checked="" disabled="" /> force_b64 flag to force conversion of images from URLs to base64 format
    • <input type="checkbox" checked="" disabled="" /> click on image to enlarge
    • <input type="checkbox" checked="" disabled="" /> control number of displayed images and their width through max_images and img_width params
    • <input type="checkbox" checked="" disabled="" /> "show html" button which reveals the HTML code used to generate plots
    • <input type="checkbox" checked="" disabled="" /> option to set specific order of labels/tabs, filter them or ignore some of the labels
  • <input type="checkbox" checked="" disabled="" /> Supported notebook platforms:
    • <input type="checkbox" checked="" disabled="" /> Jupyter
    • <input type="checkbox" checked="" disabled="" /> Google Colab
    • <input type="checkbox" checked="" disabled="" /> Azure Notebooks
    • <input type="checkbox" checked="" disabled="" /> Kaggle Notebooks

Getting Started

To start using IPyPlot, see examples below or go to gear-images-examples.ipynb notebook which takes you through most of the scenarios and options possible with IPyPlot.

Installation

IPyPlot can be installed through PyPI:

pip install ipyplot

or directly from this repo using pip:

pip install git+https://github.com/karolzak/ipyplot

Usage examples

IPyPlot offers 3 main functions which can be used for displaying images in notebooks:

To start working with IPyPlot you need to simply import it like this:

import ipyplot

and use any of the available plotting functions shown below (notice execution times).

  • images - should be a sequence of either string (local or remote image file URLs), PIL.Image objects or numpy.ndarray objects representing images
  • labels - should be a sequence of string or int

Display a collection of images

Display class representations (first image for each unique label)

Display images in separate, interactive tabs for each unique class

To learn more about what you can do with IPyPlot go to gear-images-examples.ipynb notebook for more complex examples.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ipyplot, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size ipyplot-1.1.0-py3-none-any.whl (13.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ipyplot-1.1.0.tar.gz (12.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page