Skip to main content

TensorFlow-ResNets

PyPI version

This repository contains TensorFlow Keras ResNet models. Below, you will find the supported variants of ResNet and what weights are supported.

The codebase takes inspiration from TensorFlow ResNets and PyTorch ResNets.

This repository is compatible with TF 2.2.0 even though grouped convolutions are only supported in TF Nightly. Grouped convolutions will be imported from convolutions.py which is the TF Nightly version of convolution layers. This allows the use of TPUs since they don't work with TF Nightly.

These models will not work without a GPU or TPU due to the use of grouped convolutions.

Installation


To install, you can use pip install tf2-resnets.
To use a model, you can do

from tf2_resnets import models

# Weights here are ImageNet.
# They can also be 'ssl' (semi-supervised)
# or 'swsl' (semi-weakly supervised)
# for a selection of models.
model = models.ResNeXt50(input_shape=(224, 224, 3), weights='imagenet')

Models


Architecture Weights Top-1 Acc. Top-5 Acc.
ResNet-18 ImageNet 69.8 89.1
ResNet-34 ImageNet 73.3 91.4
ResNet-50 ImageNet 76.2 92.9
ResNet-101 ImageNet 77.4 93.6
ResNet-152 ImageNet 78.3 94.1
ResNeXt-50 32x4d ImageNet 77.6 93.7
ResNeXt-101 32x8d ImageNet 79.3 94.5
Wide ResNet-50 2 ImageNet 78.5 94.1
Wide ResNet-101 2 ImageNet 78.8 94.3
ResNeSt-50 ImageNet 81.0* N/A
ResNeSt-101 ImageNet 82.8* N/A
ResNeSt-200 ImageNet 83.8* N/A
ResNeSt-269 ImageNet 84.5* N/A
ResNet-18 semi-supervised 72.8 91.5
ResNet-50 semi-supervised 79.3 94.9
ResNet-18 semi-weakly supervised 73.4 91.9
ResNet-50 semi-weakly supervised 81.2 96.0
ResNeXt-50 32x4d semi-supervised 80.3 95.4
ResNeXt-101 32x8d semi-supervised 81.7 96.1
ResNeXt-50 32x4d semi-weakly supervised 82.2 96.3
ResNeXt-101 32x8d semi-weakly supervised 84.3 97.2

* ResNeSt models' Top-1 Accuracies were reported using different crop sizes. Crop sizes in order - 224, 256, 320, and 416.

Preprocessing


There are two different preprocessing functions which are meant to be used according to the task at hand. The first one, located in imagenet_preprocessing.py, is meant to be used for reproducing the ImageNet results. The second function is located inside resnet.py. This function is meant to be used for transfer learning. The first function includes an additional resize to 256 by 256 and a central crop to 224 by 224.

Original Implementations


The original implementions of these models are listed below.

Release files for tf2-resnets 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tf2-resnets 0.3.0
File Size Uploaded
tf2-resnets-0.3.0.tar.gz 27.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tf2-resnets 0.3.0
File Interpreter ABI Platform
tf2_resnets-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.9 kB

Release files / tf2-resnets-0.3.0.tar.gz

Download URL tf2-resnets-0.3.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ad040530edc535d73c53a0861182a3f12114a13ec881dd6f98eef2c400c0f394
BLAKE2b-256 checksum
How to use checksums
88bae8930614a401449f65f3717fdd56b6c048d455efd1765ffdda07d8e04b12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / tf2_resnets-0.3.0-py3-none-any.whl

Download URL tf2_resnets-0.3.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57d53b2bea63c552b052e822a736216210d395a39e39bd593a7bac95c1a416fc
BLAKE2b-256 checksum
How to use checksums
712ef63ba16e375cfd2d1964795a64d81d3b246b13d9bc52ea1cd0073cc0ee42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page