Skip to main content

Pytorch Feature Map Extractor

Project description

MapExtrakt

Release

Convolutional Neural Networks Are Beautiful

We all take our eyes for granted, we glance at an object for an instant and our brains can identify with ease. However distorted the information may be, we do a pretty good job at it.

Low light, obscured vision, poor eyesight... There are a myriad of situations where conditions are poor but still we manage to understand what an object it. Context helps, but we humans were created with sight in mind.

Computers have a harder time, but modern advances with convolutional neural networks are making this task a reality and have now surpassed human level accuracy.

Computers are beautiful, neural networks are beautiful. And the maps they create to determine what makes a cat a cat are beautiful.


MapExtrakt makes viewing feature maps a breeze.

Catch a glimpse of how a computer can see.

MapExtrakt Usage


First import your model

import torchvision
model = torchvision.models.vgg19(pretrained=True)

Import MapExtract's Feature Extractor and load in the model

from MapExtrackt import FeatureExtractor
fe = FeatureExtractor(model)

Set image to be analysed - input can be PIL Image, Numpy array or filepath. We are using the path

fe.set_image("pug.jpg")

View Layers

fe.display_from_map(layer_no=1)

Example Output

View Single Cells At a Time

fe.display_from_map(layer_no=2, cell_no=4)

Example Output

Slice the class to get a range of cells (Layer 2 Cells 0-9)

fe[2,0:10]

Example Output

Or Export Layers To Video

fe.write_video(out_size=(1200,800), file_name="output.avi", time_for_layer=60, transition_perc_layer=0.2)
MapExtrackt

More Examples

For LOTS more - view the jupyter notebook.

Examples


Installation

It's as easy as PyPI

pip install mapextrackt

or build from source in terminal

git clone https://github.com/lewis-morris/mapextrackt &&\
cd mapextrackt &&\
pip install -e .

Todo List

  • Add the ability to slice the class i.e FeatureExtractor[1,3]
  • Show parameters on the image
  • Fix video generation
  • Enable individual cells to be added to video
  • Add video parameters such as duration in seconds.
  • Clean up code
  • Make speed improvements

Author

Created by me, initially to view the outputs for my own pleasure.

If anyone has any suggestions or requests please send them over I'd be more than happy to consider.

lewis.morris@gmail.com

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

mapextrackt-0.4.tar.gz (11.2 kB view details)

Uploaded Source

Built Distributions

mapextrackt-0.4-py3.7.egg (24.2 kB view details)

Uploaded Source

mapextrackt-0.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file mapextrackt-0.4.tar.gz.

File metadata

  • Download URL: mapextrackt-0.4.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for mapextrackt-0.4.tar.gz
Algorithm Hash digest
SHA256 3b609b068f5e5d007a532cc0bd3a1d649c68578fe8a658fd0c07bfa50ee40f89
MD5 f684f69ee1f631148844e101d7f0a992
BLAKE2b-256 d0e3250cf64d58a559c4f915436046d30558f508c01724d46cfac6f29745b214

See more details on using hashes here.

File details

Details for the file mapextrackt-0.4-py3.7.egg.

File metadata

  • Download URL: mapextrackt-0.4-py3.7.egg
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for mapextrackt-0.4-py3.7.egg
Algorithm Hash digest
SHA256 48bc27ca12b725018d96414adee3e9487b97fda3e69a60247a198ee358f3e79b
MD5 e93e3b588938a4b2217951718f221e91
BLAKE2b-256 4ec66a50540fb0c5e6e7f54aee548ce0f36578422e203fbc94e5925569fa2e78

See more details on using hashes here.

File details

Details for the file mapextrackt-0.4-py3-none-any.whl.

File metadata

  • Download URL: mapextrackt-0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for mapextrackt-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 924e389fbd97eae277ec1942a4205da235d875420d306225fe8e59138346a1ac
MD5 987b7b145b168cf950d53588961d5291
BLAKE2b-256 e3de25d28a707476ce3af64cc3a06f731ea4bb7c9e753e060564469c4febe316

See more details on using hashes here.

Supported by

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