From 7d17394bdc76284e70e49b7dbeea92b4ae1543ca Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Mon, 10 Jun 2019 13:11:36 -0700 Subject: [PATCH] Add native PyTorch weights for EfficientNet-B0 w/ top-1 > 76.9 * also add pooling details to default cfg for efficiennets so testtimepool wrapper works --- README.md | 1 + models/gen_efficientnet.py | 22 ++++++++++++++-------- models/test_time_pool.py | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f063e4ae..c2313cba 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ I've leveraged the training scripts in this repository to train a few of the mod |---|---|---|---|---| | resnext50_32x4d | 78.512 (21.488) | 94.042 (5.958) | 25M | bicubic | | seresnext26_32x4d | 77.104 (22.896) | 93.316 (6.684) | 16.8M | bicubic | +| efficientnet_b0 | 76.912 (23.088) | 93.210 (6.790) | 5.29M | bicubic | | mobilenetv3_100 | 75.634 (24.366) | 92.708 (7.292) | 5.5M | bicubic | | fbnetc_100 | 75.124 (24.876) | 92.386 (7.614) | 5.6M | bilinear | | resnet34 | 75.110 (24.890) | 92.284 (7.716) | 22M | bilinear | diff --git a/models/gen_efficientnet.py b/models/gen_efficientnet.py index 2b3d831f..aef2c1b9 100644 --- a/models/gen_efficientnet.py +++ b/models/gen_efficientnet.py @@ -74,23 +74,29 @@ default_cfgs = { url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/fbnetc_100-c345b898.pth'), 'spnasnet_100': _cfg( url='https://www.dropbox.com/s/iieopt18rytkgaa/spnasnet_100-048bc3f4.pth?dl=1'), - 'efficientnet_b0': _cfg(url=''), - 'efficientnet_b1': _cfg(url='', input_size=(3, 240, 240)), - 'efficientnet_b2': _cfg(url='', input_size=(3, 260, 260)), - 'efficientnet_b3': _cfg(url='', input_size=(3, 300, 300)), - 'efficientnet_b4': _cfg(url='', input_size=(3, 380, 380)), + 'efficientnet_b0': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/efficientnet_b0-d6904d92.pth', + interpolation='bicubic'), + 'efficientnet_b1': _cfg( + url='', input_size=(3, 240, 240), pool_size=(8, 8)), + 'efficientnet_b2': _cfg( + url='', input_size=(3, 260, 260), pool_size=(9, 9)), + 'efficientnet_b3': _cfg( + url='', input_size=(3, 300, 300), pool_size=(10, 10)), + 'efficientnet_b4': _cfg( + url='', input_size=(3, 380, 380), pool_size=(12, 12)), 'tf_efficientnet_b0': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0-0af12548.pth', input_size=(3, 224, 224), interpolation='bicubic'), 'tf_efficientnet_b1': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b1-5c1377c4.pth', - input_size=(3, 240, 240), interpolation='bicubic', crop_pct=0.882), + input_size=(3, 240, 240), pool_size=(8, 8), interpolation='bicubic', crop_pct=0.882), 'tf_efficientnet_b2': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b2-e393ef04.pth', - input_size=(3, 260, 260), interpolation='bicubic', crop_pct=0.890), + input_size=(3, 260, 260), pool_size=(9, 9), interpolation='bicubic', crop_pct=0.890), 'tf_efficientnet_b3': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b3-e3bd6955.pth', - input_size=(3, 300, 300), interpolation='bicubic', crop_pct=0.904), + input_size=(3, 300, 300), pool_size=(10, 10), interpolation='bicubic', crop_pct=0.904), } _DEBUG = False diff --git a/models/test_time_pool.py b/models/test_time_pool.py index 9aafeba9..b24d82a3 100644 --- a/models/test_time_pool.py +++ b/models/test_time_pool.py @@ -31,7 +31,7 @@ def apply_test_time_pool(model, config, args): if not args.no_test_pool and \ config['input_size'][-1] > model.default_cfg['input_size'][-1] and \ config['input_size'][-2] > model.default_cfg['input_size'][-2]: - print('Target input size (%s) > pretrained default (%s), using test time pooling' % + print('Target input size %s > pretrained default %s, using test time pooling' % (str(config['input_size'][-2:]), str(model.default_cfg['input_size'][-2:]))) model = TestTimePoolHead(model, original_pool=model.default_cfg['pool_size']) test_time_pool = True