Skip to main content

Library for training deep neural nets in Pytorch.

Project description


Licence Python Downloads Contributions welcome

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


  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


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


pip install deepml


1. Create torch data loaders.

import torch

train_loader = # your train loader instance of
val_loader = # your val loader instance of

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", 
                                     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, 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)


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)


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.


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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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