• Stars
    star
    381
  • Rank 112,502 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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_imgs_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.

More Repositories

1

keras-unet

Helper package with multiple U-Net implementations in Keras as well as useful utility tools helpful when working with image semantic segmentation tasks. This library and underlying tools come from multiple projects I performed working on semantic segmentation tasks
Python
334
star
2

support-tickets-classification

This case study shows how to create a model for text analysis and classification and deploy it as a web service in Azure cloud in order to automatically classify support tickets. This project is a proof of concept made by Microsoft (Commercial Software Engineering team) in collaboration with Endava http://endava.com/en
Python
167
star
3

boxdetect

BoxDetect is a Python package based on OpenCV which allows you to easily detect rectangular shapes like character or checkbox boxes on scanned forms.
Python
88
star
4

conv3d-video-action-recognition

My experimentation around action recognition in videos. Contains Keras implementation for C3D network based on original paper "Learning Spatiotemporal Features with 3D Convolutional Networks", Tran et al. and it includes video processing pipelines coded using mPyPl package. Model is being benchmarked on popular UCF101 dataset and achieves results similar to those reported by authors
Python
51
star
5

cntk-hotel-pictures-classificator

This POC is using CNTK 2.1 to train model for multiclass classification of images. Our model is able to recognize specific objects (i.e. toilet, tap, sink, bed, lamp, pillow) connected with picture types we are looking for. It plays a big role in a process which will be used to classify pictures from different hotels and determine whether it's a picture of bathroom, bedroom, hotel front, swimming pool, bar, etc.
Python
38
star
6

cntk-python-web-service-on-azure

This sample project shows off how to prepare and deploy to Azure Web Apps a simple Python web service with an image classifying model produced in CNTK (Cognitive Toolkit) using FasterRCNN
Python
25
star
7

images-vector-search

Simple implementation of search for visually similar images using deep learning and vector search. It's based on pretrained ImageNet weights so it doesnt require any additional training
Python
8
star
8

mobile-app-documentdb-offlinesync-sample

This is a proof of concept project where we tight up a DocumentDB instance with complex (nested) types with several SQLite mobile clients using Azure Mobile Apps with Offline Sync.
C#
7
star
9

xamarin-mvvmcross-and-web-service-sample

This is a sample LOB application for iOS, Android and Windows UWP, written with Xamarin Native approach
C#
2
star
10

adventofcode

Jupyter Notebook
1
star
11

xaml-blend-tutorial

C#
1
star