Skip to main content

Python package that provides a well-documented and easy to use implementation of ResNet (and ResNetv1.5), together with its most basic use case of image classification.

Project description

resnet-simple

Python Version GitHub license PyPI downloads Open All Collab

resnet-simple is a Python3 library that provides a well-documented and easy to use implementation of ResNet (and ResNetv1.5), together with its most basic use case of image classification.

ResNet

Residual Network, more commonly known as ResNet, is a deep learning model that is most commonly used for image recogition and classification. It was first introduced by He et al. in the paper titled "Deep Residual Learning for Image Recognition". Each ResNet has multiple residual blocks that takes an input $x$ and pass it through stacked non-linear layers which are fit to the residual mapping $F(x) := H(x) - x$, where $H(x)$ is the original unreferenced mapping which can be recast back via $H(x) = F(x) + x$. Intuitively speaking, ResNets should achieve higher accuracy than models that purely use convolutional networks (CNNs) such as VGGNet and AlexNet, as technically it should be easier to optimize and learn residual mapping than an unreferenced one.

This module allows you to choose between the original ResNet (v1) and the modified ResNet (v1.5), in which the latter enjoys a slight increase in accuracy at the expense of a slower performance. To do so, set downsample_3x3 = True under the BottleNeck/ResNet class to use ResNetv1.5, and downsample_3x3 = False for ResNetv1. This feature only works for ResNets that use BottleNeck blocks such as ResNet50, ResNet101 and ResNet152.

How to use resnet-simple

resnet-simple only supports python 3.7 and above. If you want to use resnet-simple for other versions of Python, do note that it may not function as intended.

Module is mainly tested on Google Colab (GPU) and Windows (CPU). Issues when setting up in other environments, or when using multiple GPU cores, are still relatively unknown.

Dependencies

The following libraries are compulsory in order to use resnet-simple, which is automatically installed together with it unless otherwise specified:

  • tqdm
  • torch
  • safetensors

When pip installing resnet-simple, the following libraries will also be installed as they are used in our examples:

  • matplotlib
  • torchvision
  • tensorboard
  • scikit-learn (for Python 3.7, use version 1.0.2)

User installation

In command prompt on Windows,

pip install resnet-simple

In your python file,

from resnet_simple import *

Contributions

I appreciate if you are able to contribute to this project as I am the only contributor for now. If you think that something is wrong with my code, you can open an issue and I'll try my best to resolve it!

Citation

The code from this module is re-implemented based on what was described in the following paper.

@inproceedings{inproceedings,
author = {He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
year = {2016},
month = {06},
pages = {770-778},
title = {Deep Residual Learning for Image Recognition},
doi = {10.1109/CVPR.2016.90}
}@misc{he2015deep,
      title={Deep Residual Learning for Image Recognition}, 
      author={Kaiming He and Xiangyu Zhang and Shaoqing Ren and Jian Sun},
      year={2015},
      eprint={1512.03385},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

resnet_simple-1.0.1-py3-none-any.whl (9.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