mrT23 / TResNet

TOP 1 ACCURACY TOP 5 ACCURACY
SPEED
MODEL CODE PAPER
ε-REPR
CODE PAPER
ε-REPR
PAPER
GLOBAL RANK
TResNet-L
81.4% 81.4% 95.6% 95.6% 496.3 #161
TResNet-L
(288-Mean-Max)
82.0% 81.4%
96.1% 95.6%
356.4 #119
TResNet-L
(input=448)
83.8% 83.8% 96.7% -- 161.6 #77
TResNet-M
80.7% 80.7% 94.8% 94.8% 507.5 #178
TResNet-M
(288-Mean-Max)
81.6% 80.7%
95.4% 94.8%
410.9 #139
TResNet-M
(input=288)
81.4% 80.7%
95.2% 94.8%
409.8 #150
TResNet-M
(input=448)
83.2% 83.2% 96.2% -- 289.5 #112
TResNet-XL
82.0% 82.0% 95.9% 95.9% 445.4 #134
TResNet-XL
(288-Mean-Max)
82.8% 82.0%
96.3% 95.9%
256.5 #103
TResNet-XL
(input=448)
84.3% 84.3% 96.9% -- 123.8 #66
See Full Build Details +get badge code
[![SotaBench](https://img.shields.io/endpoint.svg?url=https://sotabench.com/api/v0/badge/gh/hussam789/TResNet)](https://sotabench.com/user/hussam.lawen/repos/hussam789/TResNet)

How the Repository is Evaluated

The full sotabench.py file - source
import gc

from torchbench.image_classification import ImageNet
import urllib.request
import torch
from torchvision.transforms import transforms
from src.helper_functions.helper_functions import validate, create_dataloader
from src.models import create_model
import argparse

from src.models.tresnet.tresnet import InplacABN_to_ABN
from src.models.utils.fuse_bn import fuse_bn_recursively
from src.models.tresnet.layers.avg_pool import TestTimePoolHead

parser = argparse.ArgumentParser(description='PyTorch TResNet ImageNet Inference')
parser.add_argument('--val_dir')
parser.add_argument('--model_path')
parser.add_argument('--model_name', type=str, default='tresnet_m')
parser.add_argument('--num_classes', type=int, default=1000)
parser.add_argument('--input_size', type=int, default=224)
parser.add_argument('--val_zoom_factor', type=int, default=0.875)
parser.add_argument('--batch_size', type=int, default=48)
parser.add_argument('--num_workers', type=int, default=8)

# parsing args
args = parser.parse_args()
# TResNet-M
model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(int(args.input_size / args.val_zoom_factor)),
     transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-M')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-M',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=432,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-M-288
model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(int(288 / args.val_zoom_factor)),
     transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-M-288')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-M (input=288)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=352,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# MTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(288),
     transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-M (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-M (288-Mean-Max)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=432,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-L
args.model_name = 'tresnet_l'
model_path = './tresnet_l.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(int(args.input_size / args.val_zoom_factor)),
     transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-L')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-L',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=250,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.814, 'Top 5 Accuracy': 0.956},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# LTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(288),
     transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_l.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-L (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-L (288-Mean-Max)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=250,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.814, 'Top 5 Accuracy': 0.956},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-XL
args.model_name = 'tresnet_xl'
model_path = './tresnet_xl.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(int(args.input_size / args.val_zoom_factor)),
     transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())
    
print('Benchmarking TResNet-XL')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-XL',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=250,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.820, 'Top 5 Accuracy': 0.959},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# XLTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize(288),
     transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_xl.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-XL (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-XL (288-Mean-Max)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=212,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.820, 'Top 5 Accuracy': 0.959},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-M-448
args.model_name = 'tresnet_m'
model_path = './tresnet_m_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())
    
print('Benchmarking TResNet-M 448')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-M (input=448)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=125,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.832},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-L-448
args.model_name = 'tresnet_l'
model_path = './tresnet_l_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())
    
print('Benchmarking TResNet-L 448')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-L (input=448)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=64,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.838},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-XL-448
args.model_name = 'tresnet_xl'
model_path = './tresnet_xl_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
    [transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())
    
print('Benchmarking TResNet-XL 448')

# Run the benchmark
ImageNet.benchmark(
    model=model,
    paper_model_name='TResNet-XL (input=448)',
    paper_arxiv_id='2003.13630',
    input_transform=val_tfms,
    batch_size=32,
    num_workers=args.num_workers,
    num_gpu=1,
    pin_memory=True,
    paper_results={'Top 1 Accuracy': 0.843},
    model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()
STATUS
BUILD
COMMIT MESSAGE
RUN TIME
Update sotabench.py
hussam789   cd22582  ·  Apr 03 2020
0h:17m:48s
Update sotabench.py
hussam789   003f23a  ·  Apr 02 2020
0h:21m:02s
Update sotabench.py
hussam789   c966a28  ·  Apr 02 2020
0h:35m:21s
Update sotabench.py
hussam789   4beda16  ·  Apr 02 2020
0h:14m:55s
Update sotabench.py
hussam789   d970307  ·  Apr 02 2020
0h:18m:10s
0h:14m:14s
Update sotabench.py
hussam789   ffbf639  ·  Apr 02 2020
0h:16m:38s
Update sotabench.py
hussam789   99ac024  ·  Apr 02 2020
0h:17m:38s
Update sotabench.py
hussam789   a72ab64  ·  Apr 02 2020
0h:06m:14s
Update sotabench.py
hussam789   ecb6bd1  ·  Apr 02 2020
0h:00m:41s
Update sotabench.py
hussam789   5458429  ·  Apr 02 2020
0h:19m:20s
Update sotabench.py
hussam789   894f4b4  ·  Apr 02 2020
0h:12m:55s
Update sotabench.py
hussam789   4fd69e8  ·  Apr 02 2020
0h:07m:05s
Update sotabench.py
hussam789   e8c6467  ·  Apr 02 2020
0h:11m:25s
Update sotabench_setup.sh
hussam789   8c24059  ·  Apr 02 2020
0h:25m:42s
Update sotabench.py
hussam789   a051df8  ·  Apr 02 2020
0h:03m:27s
Update sotabench.py
hussam789   3faeffc  ·  Apr 02 2020
0h:10m:37s
Update avg_pool.py
hussam789   334f339  ·  Apr 02 2020
0h:17m:52s
Update sotabench.py
hussam789   8a7cbff  ·  Apr 02 2020
0h:00m:50s
Update avg_pool.py
hussam789   a9f2888  ·  Apr 02 2020
0h:05m:48s
Update sotabench.py
hussam789   c3d1190  ·  Apr 02 2020
0h:08m:09s
Update avg_pool.py
hussam789   e0ebbbe  ·  Apr 02 2020
0h:05m:56s
Update sotabench.py
hussam789   60c4318  ·  Apr 02 2020
0h:05m:44s
Update tresnet.py
hussam789   ffc57d6  ·  Apr 02 2020
0h:07m:46s
Update avg_pool.py
hussam789   f91b23b  ·  Apr 02 2020
0h:00m:44s
Update sotabench.py
hussam789   0321b36  ·  Apr 02 2020
0h:10m:29s
Update sotabench.py
hussam789   f8e3d69  ·  Apr 02 2020
0h:03m:10s
TestTimePoolHead
hussam789   763950c  ·  Apr 02 2020
0h:01m:43s
Update sotabench.py
hussam789   0d2cd71  ·  Apr 02 2020
0h:17m:21s
464, 250, 250, 125
hussam789   8beb6d4  ·  Apr 02 2020
0h:15m:50s
432, 288, 288, 180
hussam789   838e463  ·  Apr 02 2020
0h:09m:31s
Update sotabench.py
hussam789   094bc13  ·  Apr 02 2020
0h:12m:46s
Update sotabench.py
hussam789   62cd3d6  ·  Apr 02 2020
0h:15m:01s
Update sotabench.py
hussam789   ddb1261  ·  Apr 01 2020
0h:14m:18s
bs=250
hussam789   ac3dd08  ·  Apr 01 2020
0h:13m:59s
Update sotabench.py
hussam789   f1b03ff  ·  Apr 01 2020
0h:12m:35s
Update sotabench.py
hussam789   2e5af26  ·  Apr 01 2020
0h:18m:48s
Update sotabench.py
hussam789   37fb185  ·  Apr 01 2020
0h:08m:55s
Update sotabench.py
hussam789   5135e64  ·  Apr 01 2020
0h:05m:50s
Update sotabench.py
hussam789   d1142d0  ·  Apr 01 2020
0h:06m:16s
Update sotabench.py
hussam789   77a3f80  ·  Apr 01 2020
0h:08m:56s
Update sotabench.py
hussam789   ca6ab4e  ·  Apr 01 2020
0h:07m:38s
Update sotabench.py
hussam789   df7a141  ·  Apr 01 2020
unknown
Update sotabench_setup.sh
hussam789   524ca28  ·  Apr 01 2020
0h:14m:29s
Update sotabench.py
hussam789   a3ff571  ·  Apr 01 2020
0h:09m:06s
Update sotabench.py
hussam789   55295af  ·  Apr 01 2020
0h:17m:28s
last try
mrT23 a2ac202    d993ec9  ·  Apr 01 2020
0h:15m:55s
install zlib
hussam789   a45609d  ·  Apr 01 2020
0h:07m:42s
try only pillow
mrT23   dd1d42d  ·  Apr 01 2020
unknown
mtresnet_batch_size=320, ltresnet_batch_size=288
hussam789   f279f57  ·  Apr 01 2020
0h:08m:52s
Update sotabench_setup.sh
hussam789   af3e4e3  ·  Apr 01 2020
0h:05m:58s
force uninstall
hussam789   9cf2cea  ·  Apr 01 2020
0h:06m:07s
XLTresnet batch_size=160
hussam789   a767dd2  ·  Apr 01 2020
0h:07m:46s
CC="cc -mavx2" python3 -m pip install -U --force-reinstall pillo…
mrT23   c856858  ·  Apr 01 2020
0h:05m:40s
python3 -m pip install --upgrade pip python3 -m pip install --up…
mrT23   7ddac7f  ·  Apr 01 2020
0h:05m:45s
pip uninstall pillow CC="cc -mavx2" pip install -U --force-reins…
mrT23   592371c  ·  Apr 01 2020
0h:05m:53s
try conda
mrT23   aecfcfa  ·  Apr 01 2020
0h:05m:50s
python -m pip install -U --force-reinstall pip
mrT23   5dc58b6  ·  Apr 01 2020
0h:08m:15s
export DEBIAN_FRONTEND=noninteractive
mrT23   e31c633  ·  Apr 01 2020
unknown
export DEBIAN_FRONTEND="noninteractive"
mrT23   fbfd96d  ·  Apr 01 2020
0h:10m:29s
# pillow simd try1
mrT23   b3f5819  ·  Apr 01 2020
0h:08m:43s
try bn fusion
mrT23   8990af1  ·  Apr 01 2020
0h:20m:54s
pin_memory
hussam789   55f722e  ·  Apr 01 2020
0h:15m:33s
Update README.md
hussam789   da6f186  ·  Apr 01 2020
0h:06m:14s
Update sotabench.py
hussam789   607f280  ·  Apr 01 2020
0h:14m:31s
Update sotabench.py
hussam789   4afe388  ·  Apr 01 2020
0h:08m:13s
Update sotabench.py
hussam789   c5e013b  ·  Apr 01 2020
0h:13m:14s
Update sotabench.py
hussam789   8fcad97  ·  Apr 01 2020
0h:10m:20s
Update sotabench_setup.sh
hussam789   fe19184  ·  Apr 01 2020
0h:13m:52s
Update sotabench.py
hussam789   386ea4d  ·  Apr 01 2020
0h:05m:17s
Update sotabench.py
hussam789   5f45443  ·  Apr 01 2020
0h:11m:18s
Update sotabench_setup.sh
hussam789   563253b  ·  Apr 01 2020
0h:03m:00s
Update sotabench_setup.sh
hussam789   0be4368  ·  Apr 01 2020
unknown
Update sotabench.py
hussam789   a59c0f9  ·  Apr 01 2020
0h:06m:42s
Update sotabench.py
hussam789   bc17ac6  ·  Apr 01 2020
0h:03m:11s
Update sotabench_setup.sh
hussam789   0e0727a  ·  Apr 01 2020
0h:03m:07s
Create sotabench_setup.sh
hussam789   01f85e9  ·  Apr 01 2020
0h:07m:08s
Update requirements.txt
hussam789   9f055d3  ·  Mar 31 2020
0h:02m:06s
Update requirements.txt
hussam789   ed3f377  ·  Mar 31 2020
0h:01m:25s
Update requirements.txt
hussam789   3bfb2eb  ·  Mar 31 2020
0h:02m:42s
Add Sotabench.py
hussam789   17d194f  ·  Mar 31 2020
0h:06m:52s
0h:02m:17s