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:

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

images = [
    "docs/example1-tabs.jpg",
    "docs/example2-images.jpg",
    "docs/example3-classes.jpg",
]
ipyplot.plot_images(images, max_images=30, img_width=150)

Display class representations (first image for each unique label)

images = [
    "docs/example1-tabs.jpg",
    "docs/example2-images.jpg",
    "docs/example3-classes.jpg",
]
labels = ['label1', 'label2', 'label3']
ipyplot.plot_class_representations(images, labels, img_width=150)

Display images in separate, interactive tabs for each unique class

images = [
    "docs/example1-tabs.jpg",
    "docs/example2-images.jpg",
    "docs/example3-classes.jpg",
]
labels = ['class1', 'class2', 'class3']
ipyplot.plot_class_tabs(images, labels, max_images_per_tab=10, img_width=150)

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

Project details


Download files

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

Source Distribution

ipyplot-1.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipyplot-1.1.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file ipyplot-1.1.1.tar.gz.

File metadata

  • Download URL: ipyplot-1.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for ipyplot-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c5807454723c830581f24a977845b46fddd896c2b773fb2d830c7b34bf12b41c
MD5 14b5b0d8f841636cc245cf6a225bb972
BLAKE2b-256 6e46cf95ea520b0c7c57f789646ec21deb04005f54101636fc1533bf7d2a8664

See more details on using hashes here.

File details

Details for the file ipyplot-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: ipyplot-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for ipyplot-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 837ed15f47eee18b476c9bca78b46437b64944b71e5e0f0ac560cb758128d16d
MD5 e499f326783100bab9628b9a85c570a6
BLAKE2b-256 c317ec232743661283c6eeaaedfbe99410571b41b03739a3808916487a6fe785

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page