saiamrit / lightning-image-models

Image classification models implemented in Pytorch Lightning with Weights and Biases logging integrated to track the metrics and losses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pytorch Lightning Image Classification Models

Lightning Python PyTorch W & B

Open In Colab

This repository contains image classification models implemented in Pytorch Lightning. The logging is done with Weights and Biases, integrated to track the metrics and losses. The aim is also to present a clean templete for Pytorch Lightning projects, and present modular and structured code for projects build with Pytorch lightning.

Requirements

 opencv=4.1.2
 pytorch=1.9.1
 torchvision=0.10.1
 pytorch-lightning=1.5.10
 scikit-image=0.15.0
 wandb

Models

  • AlexNet

Setting up the Project

The project was built in a conda environment. So it is recommended but not necessary to have anaconda/miniconda installed. The environment.yml has the necessary environment packages.

Clone the repository to your local using,

git clone https://github.com/saiamrit/lightning-image-models.git
cd lightning-image-models

Then setup the conda environment using,

conda env create -f environment.yml

Running

Once the environment is created, activate the environment and run the traintest.p

How to run

First, install dependencies

# clone project   
git clone https://github.com/saiamrit/lightning-image-models.git

# install project   
cd deep-learning-project-template 
pip install -e .   
pip install -r requirements.txt

Next, navigate to any file and run it.

# module folder
cd project

# run module (example: mnist as your main contribution)   
python lit_classifier_main.py    

Imports

This project is setup as a package which means you can now easily import any file into any other file like so:

from project.datasets.mnist import mnist
from project.lit_classifier_main import LitClassifier
from pytorch_lightning import Trainer

# model
model = LitClassifier()

# data
train, val, test = mnist()

# train
trainer = Trainer()
trainer.fit(model, train, val)

# test using the best model!
trainer.test(test_dataloaders=test)

Citation

@article{YourName,
  title={Your Title},
  author={Your team},
  journal={Location},
  year={Year}
}

About

Image classification models implemented in Pytorch Lightning with Weights and Biases logging integrated to track the metrics and losses


Languages

Language:Python 100.0%