Skip to content

Commit 1228f5a

Browse files
committed
Add BiT distilled 50x1 and teacher 152x2 models from 'A good teacher is patient and consistent' paper.
1 parent 511a8e8 commit 1228f5a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

timm/models/resnetv2.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Thanks to the Google team for the above two repositories and associated papers:
1212
* Big Transfer (BiT): General Visual Representation Learning - https://arxiv.org/abs/1912.11370
1313
* An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale - https://arxiv.org/abs/2010.11929
14+
* Knowledge distillation: A good teacher is patient and consistent - https://arxiv.org/abs/2106.05237
1415
1516
Original copyright of Google code below, modifications by Ross Wightman, Copyright 2020.
1617
"""
@@ -86,6 +87,16 @@ def _cfg(url='', **kwargs):
8687
url='https://storage.googleapis.com/bit_models/BiT-M-R152x4.npz',
8788
num_classes=21843),
8889

90+
'resnetv2_50x1_bit_distilled': _cfg(
91+
url='https://storage.googleapis.com/bit_models/distill/R50x1_224.npz',
92+
input_size=(3, 224, 224), crop_pct=0.875, interpolation='bicubic'),
93+
'resnetv2_152x2_bit_teacher': _cfg(
94+
url='https://storage.googleapis.com/bit_models/distill/R152x2_T_224.npz',
95+
input_size=(3, 224, 224), crop_pct=0.875, interpolation='bicubic'),
96+
'resnetv2_152x2_bit_teacher_384': _cfg(
97+
url='https://storage.googleapis.com/bit_models/distill/R152x2_T_384.npz',
98+
input_size=(3, 384, 384), crop_pct=1.0, interpolation='bicubic'),
99+
89100
'resnetv2_50': _cfg(
90101
input_size=(3, 224, 224), crop_pct=0.875, interpolation='bicubic'),
91102
'resnetv2_50d': _cfg(
@@ -521,6 +532,33 @@ def resnetv2_152x4_bitm_in21k(pretrained=False, **kwargs):
521532
layers=[3, 8, 36, 3], width_factor=4, **kwargs)
522533

523534

535+
@register_model
536+
def resnetv2_50x1_bit_distilled(pretrained=False, **kwargs):
537+
""" ResNetV2-50x1-BiT Distilled
538+
Paper: Knowledge distillation: A good teacher is patient and consistent - https://arxiv.org/abs/2106.05237
539+
"""
540+
return _create_resnetv2_bit(
541+
'resnetv2_50x1_bit_distilled', pretrained=pretrained, layers=[3, 4, 6, 3], width_factor=1, **kwargs)
542+
543+
544+
@register_model
545+
def resnetv2_152x2_bit_teacher(pretrained=False, **kwargs):
546+
""" ResNetV2-152x2-BiT Teacher
547+
Paper: Knowledge distillation: A good teacher is patient and consistent - https://arxiv.org/abs/2106.05237
548+
"""
549+
return _create_resnetv2_bit(
550+
'resnetv2_152x2_bit_teacher', pretrained=pretrained, layers=[3, 8, 36, 3], width_factor=2, **kwargs)
551+
552+
553+
@register_model
554+
def resnetv2_152x2_bit_teacher_384(pretrained=False, **kwargs):
555+
""" ResNetV2-152xx-BiT Teacher @ 384x384
556+
Paper: Knowledge distillation: A good teacher is patient and consistent - https://arxiv.org/abs/2106.05237
557+
"""
558+
return _create_resnetv2_bit(
559+
'resnetv2_152x2_bit_teacher_384', pretrained=pretrained, layers=[3, 8, 36, 3], width_factor=2, **kwargs)
560+
561+
524562
@register_model
525563
def resnetv2_50(pretrained=False, **kwargs):
526564
return _create_resnetv2(

0 commit comments

Comments
 (0)