Skip to content

Latest commit

 

History

History
 
 

resnet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ResNet

Deep Residual Learning for Image Recognition

Introduction

Residual Networks, or ResNets, learn residual functions with reference to the layer inputs, instead of learning unreferenced functions. In the mainstream previous works, like VGG, the neural networks are a stack of layers and every layer attempts to fit a desired underlying mapping. In ResNets, a few stacked layers are grouped as a block, and the layers in a block attempts to learn a residual mapping.

Formally, denoting the desired underlying mapping of a block as $\mathcal{H}(x)$, split the underlying mapping into the sum of the identity and the residual mapping as $\mathcal{H}(x) = x + \mathcal{F}(x)$, and let the stacked non-linear layers fit the residual mapping $\mathcal{F}(x)$.

Many works proved this method makes deep neural networks easier to optimize, and can gain accuracy from considerably increased depth. Recently, the residual structure is widely used in various models.

Abstract

Show the paper's abstract
Deeper neural networks are more difficult to train. We present a residual learning framework to ease the training of networks that are substantially deeper than those used previously. We explicitly reformulate the layers as learning residual functions with reference to the layer inputs, instead of learning unreferenced functions. We provide comprehensive empirical evidence showing that these residual networks are easier to optimize, and can gain accuracy from considerably increased depth. On the ImageNet dataset we evaluate residual nets with a depth of up to 152 layers---8x deeper than VGG nets but still having lower complexity. An ensemble of these residual nets achieves 3.57% error on the ImageNet test set. This result won the 1st place on the ILSVRC 2015 classification task. We also present analysis on CIFAR-10 with 100 and 1000 layers.

The depth of representations is of central importance for many visual recognition tasks. Solely due to our extremely deep representations, we obtain a 28% relative improvement on the COCO object detection dataset. Deep residual nets are foundations of our submissions to ILSVRC & COCO 2015 competitions, where we also won the 1st places on the tasks of ImageNet detection, ImageNet localization, COCO detection, and COCO segmentation.

How to use it?

Predict image

from mmpretrain import inference_model

predict = inference_model('resnet18_8xb16_cifar10', 'demo/bird.JPEG')
print(predict['pred_class'])
print(predict['pred_score'])

Use the model

import torch
from mmpretrain import get_model

model = get_model('resnet18_8xb16_cifar10', pretrained=True)
inputs = torch.rand(1, 3, 224, 224)
out = model(inputs)
print(type(out))
# To extract features.
feats = model.extract_feat(inputs)
print(type(feats))

Train/Test Command

Prepare your dataset according to the docs.

Train:

python tools/train.py configs/resnet/resnet18_8xb16_cifar10.py

Test:

python tools/test.py configs/resnet/resnet18_8xb16_cifar10.py https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_b16x8_cifar10_20210528-bd6371c8.pth

Models and results

Image Classification on ImageNet-1k

Model Pretrain Params (M) Flops (G) Top-1 (%) Top-5 (%) Config Download
resnet18_8xb32_in1k From scratch 11.69 1.82 69.90 89.43 config model | log
resnet34_8xb32_in1k From scratch 2.18 3.68 73.62 91.59 config model | log
resnet50_8xb32_in1k From scratch 25.56 4.12 76.55 93.06 config model | log
resnet101_8xb32_in1k From scratch 44.55 7.85 77.97 94.06 config model | log
resnet152_8xb32_in1k From scratch 60.19 11.58 78.48 94.13 config model | log
resnetv1d50_8xb32_in1k From scratch 25.58 4.36 77.54 93.57 config model | log
resnetv1d101_8xb32_in1k From scratch 44.57 8.09 78.93 94.48 config model | log
resnetv1d152_8xb32_in1k From scratch 60.21 11.82 79.41 94.70 config model | log
resnet50_8xb32-fp16_in1k From scratch 25.56 4.12 76.30 93.07 config model | log
resnet50_8xb256-rsb-a1-600e_in1k From scratch 25.56 4.12 80.12 94.78 config model | log
resnet50_8xb256-rsb-a2-300e_in1k From scratch 25.56 4.12 79.55 94.37 config model | log
resnet50_8xb256-rsb-a3-100e_in1k From scratch 25.56 4.12 78.30 93.80 config model | log
resnetv1c50_8xb32_in1k From scratch 25.58 4.36 77.01 93.58 config model | log
resnetv1c101_8xb32_in1k From scratch 44.57 8.09 78.30 94.27 config model | log
resnetv1c152_8xb32_in1k From scratch 60.21 11.82 78.76 94.41 config model | log

Image Classification on CIFAR-10

Model Pretrain Params (M) Flops (G) Top-1 (%) Config Download
resnet18_8xb16_cifar10 From scratch 11.17 0.56 94.82 config model | log
resnet34_8xb16_cifar10 From scratch 21.28 1.16 95.34 config model | log
resnet50_8xb16_cifar10 From scratch 23.52 1.31 95.55 config model | log
resnet101_8xb16_cifar10 From scratch 42.51 2.52 95.58 config model | log
resnet152_8xb16_cifar10 From scratch 58.16 3.74 95.76 config model | log

Image Classification on CIFAR-100

Model Pretrain Params (M) Flops (G) Top-1 (%) Top-5 (%) Config Download
resnet50_8xb16_cifar100 From scratch 23.71 1.31 79.90 95.19 config model | log

Image Classification on CUB-200-2011

Model Pretrain Params (M) Flops (G) Top-1 (%) Config Download
resnet50_8xb8_cub From scratch 23.92 16.48 88.45 config model | log

Citation

@inproceedings{he2016deep,
  title={Deep residual learning for image recognition},
  author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
  booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},
  pages={770--778},
  year={2016}
}