Giter Club home page Giter Club logo

saravanabalagi / imshowtools Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 4.09 MB

View images in Jupyter notebooks in a much simpler and intuitive way. Ships with a better 'imshow' function with Smart Wrap and BGR support with 'cvshow'!

Home Page: https://pypi.org/project/imshowtools/

License: MIT License

Python 1.73% Jupyter Notebook 98.27%
imshow images multiple-imageview matplotlib-figures automatic-layout imshowtools mulitple-images smart-wrap wrap-images image-layout

imshowtools's Introduction

imshowtools

This library lets you view images in Jupyter notebooks in a much simpler and intuitive way. Ships with a better 'imshow' function with Multi Images, Smart Wrap and BGR support!.

Installation

To install imshowtools, simply do

pip install imshowtools

Quick Plot

Import imshow from imshowtools and use it:

from imshowtools import imshow
import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

imshow(x_train[0])
imshow(x_train[0], x_train[1], x_train[2])
imshow(*x_train[:20], cmap='binary')
imshow(*x_train[:100], cmap='binary', size=(10, 10))

You can use any matplotlib compatible cmap

mnist

Example ipynb notebook and Python along with test images provided in the example folder.

Get Numpy Image

You can use obtain numpy image in any of ['RGB', 'RGBA', 'ARGB', 'BW', 'L', "BGR", "BGRA", "ABGR"] colorspaces.

image = imshow(*x_train[:100], return_image=True)
image = imshow(*x_train[:100], return_image="RGBA")
image = imshow(*x_train[:100], return_image="RGB")
image = imshow(*x_train[:100], return_image="BW")
print(image.shape)

# cv2.imwrite("saved_sample.png", image)
# do stuff with 'image' or even
# imshow(image)

Output:

(288, 432, 3)
(288, 432, 4)
(288, 432, 3)
(288, 432)

Rows and Columns

imshow(*x_train[:15], cmap='Purples', rows=1)
imshow(*x_train[:24], cmap='Greens', columns=4)

mnist

Open CV Images

lenna = cv2.imread('example/lenna.png')
imshow(lenna)
cvshow(lenna)
imshow(lenna, mode='BGR')

image = imshow(*[lenna for _ in range(12)], return_image="BW")
print(image.shape)
imshow(image)

lenna

Namespaces

If you do not want to use imshow directly in your app (maybe you have another function named imshow), you shall use it like

import imshowtools
imshowtools.imshow(your_image)

or if you like to use a custom namespace

import imshowtools as my_namespace
my_namespace.imshow(your_image)

Contributing

Pull requests are very welcome.

  1. Fork the repo
  2. Create new branch with feature name as branch name
  3. Check if things work with a jupyter notebook
  4. Raise a pull request

Licence

Please see attached Licence

imshowtools's People

Contributors

saravanabalagi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

imshowtools's Issues

Feature Request: pytorch and tensorflow

Nice library, I've rewritten this same function so many times, it would be great if it was standardized for all the common libs (maybe even submit a pr to matplotlib?)

Specifically it would be nice if this library transparently handed torch and tensorflow tensors and different dimension layouts (NHWC) vs (NCHW)

To use matplotlib with pytorch you always have to do something like tensor.cpu().detach().numpy().permute(0, 2, 3, 1)
before any plotting.

It makes code very ugly.

Also, in my experience using subplots is super slow and it's much better to lay things out yourself in a numpy array (haven't benchmarked your version though).

pytorch has its own version of this but it would be nice to have a common clean API I could use everywhere.

I can maybe submit a pr for this if you're interested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.