Skip to main content

Machine learning image classification library

Project description

TensorImage

TensorImage is a machine learning tool to train image recognition models, by implementing Convolutional Neural Networks. Moreover, it offers the possibility to use these models to make predictions for thousands of unclassified images quickly and easily.

Getting started

These are the steps you need to follow to get TensorImage working on your computer.

Download TensorImage

You can now download the latest TensorImage version.

Install dependencies

You have to install the dependencies that are required by TensorImage. From the terminal:

# Access repository directory
$ cd TensorImage/

# Run install script
$ python3 setup.py

Open-source libraries used by TensorImage:

Configure TensorImage

In order to get TensorImage working, you must adjust the configuration to your computer. From the terminal:

# Access repository directory
$ cd TensorImage/

# Open configuration file for editing
$ nano config.py

You should now have a terminal similar to the following:

# User configurations
workspace_dir = '/path/to/workspace/'
tensorimage_path = '/path/to/repository/'
...

Modify workspace_dir to the workspace folder that you will be using for TensorImage. It is not necessary for you to create the folder, as it will be created automatically in another step. Modify tensorimage_path to the path where TensorImage has been saved. Now save and exit the configuration file.

To finish up with setting up TensorImage, from the terminal:

# Access repository directory
$ cd TensorImage/

# Run __init__.py
$ python3 __init__.py

You are now ready to begin using TensorImage!

Usage

Preprocesing a dataset

Structuring a training dataset

For being able to add a training dataset to TensorImage, it must have the following structure:

+-- your_dataset  (directory)
|   +-- class1  (directory)
   |   image1.jpg  (image)
   |   image2.jpg  (image)
   |   image3.jpg  (image)
   |   ...         (rest of images)

|   +-- class2  (directory)
   |   image1.jpg  (image)
   |   image2.jpg  (image)
   |   image3.jpg  (image)
   |   ...         (rest of images)

|   +-- ...  (rest of directories)
   |   image1.jpg  (image)
   |   image2.jpg  (image)
   |   image3.jpg  (image)
   |   ...         (rest of images)

Adding a training dataset to TensorImage

Assuming you have already structured your dataset, from the terminal:

$ cd tensorimage/tensorimage/
$ python3 set.py add_training_dataset
$ python3 main.py data_name /path/to/training/dataset
Args:
  • data_name: a unique name assigned to a dataset used by TensorImage to identify image data
  • /path/to/training/dataset: path to the training dataset to add to TensorImage

Structuring an unclassified image dataset

Your unclassified image dataset has to have the following structure:

+-- your_dataset  (directory)
   |   image1.jpg  (image)
   |   image2.jpg  (image)
   |   image3.jpg  (image)
   |   image4.jpg  (image)
   |   image5.jpg  (image)
   |   image6.jpg  (image)
   |   ...         (rest of images)

Adding an unclassified image dataset

Again, assuming you have correctly structured your unclassified image dataset, from the terminal:

$ cd tensorimage/tensorimage
$ python3 set.py add_unclassified_dataset
$ python3 main.py data_name /path/to/unclassified/dataset
Args:
  • data_name: a unique name assigned to a dataset used by TensorImage to identify image data
  • /path/to/unclassified/dataset: path to the unclassified dataset to add to TensorImage

Training

Assuming you have already extracted the image data for your training dataset, from the terminal:

$ cd tensorimage/tensorimage
$ python3 set.py train
$ python3 main.py data_name* training_name* learning_rate* n_epochs* l2_regularization_beta* --train_test_split train_test_split --batch_size batch_size --augment_data augment_data --cnn_architecture cnn_architecture

* required

Args:
  • data_name: data name that was assigned to training dataset that TensorImage will use for training

  • training_name: unique name assigned to a training operation. TensorImage will use it to identify the model files for classification

  • learning_rate: learning rate used for training

  • n_epochs: number of epochs

  • l2_regularization_beta: beta value used for L2 regularization to reduce overfitting

  • train_test_split: proportion of input data which TensorImage will use as testing set

  • batch_size: batch size

  • augment_data: True or False, augment the input data or not

  • cnn_architecture: Convolutional Neural Network architecture that will be used. Available architectures:

    • AlexNet: to use the AlexNet architecture pass alexnet. Input shape [227x227x3]. If image dimensions are not 227x227, they will be automatically resized.
    • CNN model1: to use the CNN model1 architecture pass cnn_model1. It accepts any image size (however all image sizes must be the same), original dimensions will be kept. It has been created by TensorImage for testing purposes and has achieved up to around 94% testing accuracy and around 99% training accuracy on a reduced version of the MNIST dataset.

Visualizing training progress with TensorBoard

From the terminal:

# Access TensorBoard log directory inside your workspace
$ cd workspace_dir/user/logs

$ tensorboard --logdir training_name

Args:

  • training_name: training name that was used for the training operation that you want to visualize

Classifying

If you have already extracted the image data for an unclassified dataset, from the terminal:

$ cd tensorimage/tensorimage
$ python3 set.py classify
$ python3 main.py data_name* training_name* classification_name* --show_images show_images

* required

Args:
  • data_name: data name that was assigned to unclassified dataset that TensorImage will use for classification
  • training_name: training name assigned to training operation, from where TensorImage will use the model to classify
  • classification_name: unique name assigned to the image classification operation
  • show_images: True or False, display images with predicted labels after classification or not

License

TensorImage is licensed under the GPL-2.0 license.

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

TensorImage-1.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

TensorImage-1.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file TensorImage-1.2.0.tar.gz.

File metadata

  • Download URL: TensorImage-1.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for TensorImage-1.2.0.tar.gz
Algorithm Hash digest
SHA256 0a0c23e43374825e40306c435c3c4e5d10f85135a0b0416223385aac10a186a5
MD5 cf308e824aa02eb70f1141fb1c09f75e
BLAKE2b-256 3f81bb99552273b2567e6df2c3b9214dd903bfcd273dfa8691711c78ff96c7d1

See more details on using hashes here.

File details

Details for the file TensorImage-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: TensorImage-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for TensorImage-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a53e87ed7ddc600ad2b3c182c493506dddaef24603ac589eec6caabf1778ec24
MD5 83438eef06fce70d26176cb908088399
BLAKE2b-256 4a82a22e6995db573ee508fe5fe07f72134fe69e304263558483ec9f967d88c3

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