Skip to main content

Library for training deep neural nets in Pytorch.

Project description

deep-ml

Licence Python Downloads Contributions welcome

This library is a wrapper around pytorch and useful for solving image classification and semantic segmentation problems.

Features

  1. Easy to use wrapper around pytorch so that you can focus on training and validating your model.

  2. Integrates with Tensorboard to use it to monitor metrics while model trains.

  3. Quickly visualize your model's predictions.

  4. Following are different types of machine learning tasks available to choose from deepml.tasks:

    • ImageClassification
    • MultiLabelImageClassification
    • ImageRegression
    • Segmentation

Installation

Before installing deepml, it is recommended to refer pytorch official page for torch installation.

Pypi

pip install deepml

Usage

1. Create torch data loaders.

import torch

train_loader = # your train loader instance of torch.utils.data.DataLoader
val_loader = # your val loader instance of torch.utils.data.DataLoader

2. Create your deep neural net architecture.

import torchvision

# instance of torch.nn.Module
model = torchvision.models.vgg.vgg19(pretrained=False)

3. Choose your machine learning task.

from deepml.tasks import ImageClassification
classification = ImageClassification(model, model_dir="experiment1", 
                                     load_saved_model=False, 
                                     classes=['class1', 'class2', 'class3'])

4. Define optimizer, loss function and lr scheduler.

optimizer = torch.optim.Adam(model.parameters(), lr=0.0001)

# loss function
criterion = torch.nn.CrossEntropyLoss()

# Choose lr_scheduler if any
lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=4, gamma=0.1)

5. Quickly start training your model using deepml.train.Learner class.

from deepml.train import Learner
# instantiate learner class
learner = Learner(classification, optimizer, criterion)

# Fit Learner
learner.fit(train_loader, val_loader, epochs=10, lr_scheduler=lr_scheduler)
6. Use tensorboard to visualize model loss and metrics.
On Google Colab or Jupyter Notebook:
%load_ext tensorboard
%tensorboard --logdir 'experiment1'
On OS:
tensorboard --logdir 'experiment1'

7. Quickly see some samples predictions from data loader.

learner.show_predictions(val_loader, samples=30, cols=6, figsize=(20, 20))

8. Run prediction on data loader.

predictions, targets = learner.predict(val_loader)

Examples

Check out the below google colaboratory notebook examples:

  1. Image Regression
  2. Image Classification
  3. Binary Semantic Segmentation (Road Segmentation on Satellite Imagery)
  4. Multiclass Semantic Segmentation (Scene Understanding on Street Imagery)

Contributing

deepml is an open source project and anyone is welcome to contribute. An easy way to get started is by suggesting a new enhancement on the Issues. If you have found a bug, then either report this through Issues, or even better, make a fork of the repository, fix the bug and then create a Pull Request to get the fix into the master branch.

License

deepml is available under the MIT License. For details see the LICENSE file.

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

deepml-2.0.0.tar.gz (139.4 kB view details)

Uploaded Source

Built Distribution

deepml-2.0.0-py3-none-any.whl (143.9 kB view details)

Uploaded Python 3

File details

Details for the file deepml-2.0.0.tar.gz.

File metadata

  • Download URL: deepml-2.0.0.tar.gz
  • Upload date:
  • Size: 139.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.7

File hashes

Hashes for deepml-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a76722be19d88b2f5ddf9198b290836e448ed3d447acd06da6a38644cf209054
MD5 277400f02d3ada43f25e6774745938c1
BLAKE2b-256 cb2b09a0502e6c00b4e07a7a4008ac58b8be7d17d8c20a554d0f5293073eac7e

See more details on using hashes here.

File details

Details for the file deepml-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: deepml-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 143.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.7

File hashes

Hashes for deepml-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee72d798a137a2250e442939b47a780d45c43f6a113228d10668e118bbec7f4
MD5 db1adc721fa40c5e7db2f2e97de70184
BLAKE2b-256 3242a348f22194e7eec47593827ac34b0c9c8451148daaff666227fa85c9e8fb

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