|
2 | 2 |
|
3 | 3 | An implementation of EfficienNet that covers variety of related models with efficient architectures:
|
4 | 4 |
|
5 |
| -* EfficientNet (B0-B8 + Tensorflow pretrained AutoAug/RandAug/AdvProp weight ports) |
| 5 | +* EfficientNet (B0-B8, L2 + Tensorflow pretrained AutoAug/RandAug/AdvProp/NoisyStudent weight ports) |
6 | 6 | - EfficientNet: Rethinking Model Scaling for CNNs - https://arxiv.org/abs/1905.11946
|
7 | 7 | - CondConv: Conditionally Parameterized Convolutions for Efficient Inference - https://arxiv.org/abs/1904.04971
|
8 | 8 | - Adversarial Examples Improve Image Recognition - https://arxiv.org/abs/1911.09665
|
| 9 | + - Self-training with Noisy Student improves ImageNet classification - https://arxiv.org/abs/1911.04252 |
9 | 10 |
|
10 | 11 | * MixNet (Small, Medium, and Large)
|
11 | 12 | - MixConv: Mixed Depthwise Convolutional Kernels - https://arxiv.org/abs/1907.09595
|
@@ -91,6 +92,8 @@ def _cfg(url='', **kwargs):
|
91 | 92 | url='', input_size=(3, 600, 600), pool_size=(19, 19), crop_pct=0.949),
|
92 | 93 | 'efficientnet_b8': _cfg(
|
93 | 94 | url='', input_size=(3, 672, 672), pool_size=(21, 21), crop_pct=0.954),
|
| 95 | + 'efficientnet_l2': _cfg( |
| 96 | + url='', input_size=(3, 800, 800), pool_size=(25, 25), crop_pct=0.961), |
94 | 97 | 'efficientnet_es': _cfg(
|
95 | 98 | url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/efficientnet_es_ra-f111e99c.pth'),
|
96 | 99 | 'efficientnet_em': _cfg(
|
@@ -162,6 +165,36 @@ def _cfg(url='', **kwargs):
|
162 | 165 | url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b8_ap-00e169fa.pth',
|
163 | 166 | mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD,
|
164 | 167 | input_size=(3, 672, 672), pool_size=(21, 21), crop_pct=0.954),
|
| 168 | + 'tf_efficientnet_b0_ns': _cfg( |
| 169 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0_ns-c0e6a31c.pth', |
| 170 | + input_size=(3, 224, 224)), |
| 171 | + 'tf_efficientnet_b1_ns': _cfg( |
| 172 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b1_ns-99dd0c41.pth', |
| 173 | + input_size=(3, 240, 240), pool_size=(8, 8), crop_pct=0.882), |
| 174 | + 'tf_efficientnet_b2_ns': _cfg( |
| 175 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b2_ns-00306e48.pth', |
| 176 | + input_size=(3, 260, 260), pool_size=(9, 9), crop_pct=0.890), |
| 177 | + 'tf_efficientnet_b3_ns': _cfg( |
| 178 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b3_ns-9d44bf68.pth', |
| 179 | + input_size=(3, 300, 300), pool_size=(10, 10), crop_pct=0.904), |
| 180 | + 'tf_efficientnet_b4_ns': _cfg( |
| 181 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b4_ns-d6313a46.pth', |
| 182 | + input_size=(3, 380, 380), pool_size=(12, 12), crop_pct=0.922), |
| 183 | + 'tf_efficientnet_b5_ns': _cfg( |
| 184 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b5_ns-6f26d0cf.pth', |
| 185 | + input_size=(3, 456, 456), pool_size=(15, 15), crop_pct=0.934), |
| 186 | + 'tf_efficientnet_b6_ns': _cfg( |
| 187 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b6_ns-51548356.pth', |
| 188 | + input_size=(3, 528, 528), pool_size=(17, 17), crop_pct=0.942), |
| 189 | + 'tf_efficientnet_b7_ns': _cfg( |
| 190 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b7_ns-1dbc32de.pth', |
| 191 | + input_size=(3, 600, 600), pool_size=(19, 19), crop_pct=0.949), |
| 192 | + 'tf_efficientnet_l2_ns_475': _cfg( |
| 193 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_l2_ns_475-bebbd00a.pth', |
| 194 | + input_size=(3, 475, 475), pool_size=(15, 15), crop_pct=0.936), |
| 195 | + 'tf_efficientnet_l2_ns': _cfg( |
| 196 | + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_l2_ns-df73bb44.pth', |
| 197 | + input_size=(3, 800, 800), pool_size=(25, 25), crop_pct=0.961), |
165 | 198 | 'tf_efficientnet_es': _cfg(
|
166 | 199 | url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_es-ca1afbfe.pth',
|
167 | 200 | mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5),
|
@@ -208,7 +241,7 @@ class EfficientNet(nn.Module):
|
208 | 241 | """ (Generic) EfficientNet
|
209 | 242 |
|
210 | 243 | A flexible and performant PyTorch implementation of efficient network architectures, including:
|
211 |
| - * EfficientNet B0-B8 |
| 244 | + * EfficientNet B0-B8, L2 |
212 | 245 | * EfficientNet-EdgeTPU
|
213 | 246 | * EfficientNet-CondConv
|
214 | 247 | * MixNet S, M, L, XL
|
@@ -586,6 +619,7 @@ def _gen_efficientnet(variant, channel_multiplier=1.0, depth_multiplier=1.0, pre
|
586 | 619 | 'efficientnet-b6': (1.8, 2.6, 528, 0.5),
|
587 | 620 | 'efficientnet-b7': (2.0, 3.1, 600, 0.5),
|
588 | 621 | 'efficientnet-b8': (2.2, 3.6, 672, 0.5),
|
| 622 | + 'efficientnet-l2': (4.3, 5.3, 800, 0.5), |
589 | 623 |
|
590 | 624 | Args:
|
591 | 625 | channel_multiplier: multiplier to number of channels per layer
|
@@ -928,6 +962,24 @@ def efficientnet_b7(pretrained=False, **kwargs):
|
928 | 962 | return model
|
929 | 963 |
|
930 | 964 |
|
| 965 | +@register_model |
| 966 | +def efficientnet_b8(pretrained=False, **kwargs): |
| 967 | + """ EfficientNet-B8 """ |
| 968 | + # NOTE for train, drop_rate should be 0.5, drop_connect_rate should be 0.2 |
| 969 | + model = _gen_efficientnet( |
| 970 | + 'efficientnet_b8', channel_multiplier=2.2, depth_multiplier=3.6, pretrained=pretrained, **kwargs) |
| 971 | + return model |
| 972 | + |
| 973 | + |
| 974 | +@register_model |
| 975 | +def efficientnet_l2(pretrained=False, **kwargs): |
| 976 | + """ EfficientNet-L2.""" |
| 977 | + # NOTE for train, drop_rate should be 0.5, drop_connect_rate should be 0.2 |
| 978 | + model = _gen_efficientnet( |
| 979 | + 'efficientnet_l2', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) |
| 980 | + return model |
| 981 | + |
| 982 | + |
931 | 983 | @register_model
|
932 | 984 | def efficientnet_es(pretrained=False, **kwargs):
|
933 | 985 | """ EfficientNet-Edge Small. """
|
@@ -1166,6 +1218,109 @@ def tf_efficientnet_b8_ap(pretrained=False, **kwargs):
|
1166 | 1218 | return model
|
1167 | 1219 |
|
1168 | 1220 |
|
| 1221 | +@register_model |
| 1222 | +def tf_efficientnet_b0_ns(pretrained=False, **kwargs): |
| 1223 | + """ EfficientNet-B0 NoisyStudent. Tensorflow compatible variant """ |
| 1224 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1225 | + kwargs['pad_type'] = 'same' |
| 1226 | + model = _gen_efficientnet( |
| 1227 | + 'tf_efficientnet_b0_ns', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) |
| 1228 | + return model |
| 1229 | + |
| 1230 | + |
| 1231 | +@register_model |
| 1232 | +def tf_efficientnet_b1_ns(pretrained=False, **kwargs): |
| 1233 | + """ EfficientNet-B1 NoisyStudent. Tensorflow compatible variant """ |
| 1234 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1235 | + kwargs['pad_type'] = 'same' |
| 1236 | + model = _gen_efficientnet( |
| 1237 | + 'tf_efficientnet_b1_ns', channel_multiplier=1.0, depth_multiplier=1.1, pretrained=pretrained, **kwargs) |
| 1238 | + return model |
| 1239 | + |
| 1240 | + |
| 1241 | +@register_model |
| 1242 | +def tf_efficientnet_b2_ns(pretrained=False, **kwargs): |
| 1243 | + """ EfficientNet-B2 NoisyStudent. Tensorflow compatible variant """ |
| 1244 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1245 | + kwargs['pad_type'] = 'same' |
| 1246 | + model = _gen_efficientnet( |
| 1247 | + 'tf_efficientnet_b2_ns', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs) |
| 1248 | + return model |
| 1249 | + |
| 1250 | + |
| 1251 | +@register_model |
| 1252 | +def tf_efficientnet_b3_ns(pretrained=False, **kwargs): |
| 1253 | + """ EfficientNet-B3 NoisyStudent. Tensorflow compatible variant """ |
| 1254 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1255 | + kwargs['pad_type'] = 'same' |
| 1256 | + model = _gen_efficientnet( |
| 1257 | + 'tf_efficientnet_b3_ns', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) |
| 1258 | + return model |
| 1259 | + |
| 1260 | + |
| 1261 | +@register_model |
| 1262 | +def tf_efficientnet_b4_ns(pretrained=False, **kwargs): |
| 1263 | + """ EfficientNet-B4 NoisyStudent. Tensorflow compatible variant """ |
| 1264 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1265 | + kwargs['pad_type'] = 'same' |
| 1266 | + model = _gen_efficientnet( |
| 1267 | + 'tf_efficientnet_b4_ns', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs) |
| 1268 | + return model |
| 1269 | + |
| 1270 | + |
| 1271 | +@register_model |
| 1272 | +def tf_efficientnet_b5_ns(pretrained=False, **kwargs): |
| 1273 | + """ EfficientNet-B5 NoisyStudent. Tensorflow compatible variant """ |
| 1274 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1275 | + kwargs['pad_type'] = 'same' |
| 1276 | + model = _gen_efficientnet( |
| 1277 | + 'tf_efficientnet_b5_ns', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs) |
| 1278 | + return model |
| 1279 | + |
| 1280 | + |
| 1281 | +@register_model |
| 1282 | +def tf_efficientnet_b6_ns(pretrained=False, **kwargs): |
| 1283 | + """ EfficientNet-B6 NoisyStudent. Tensorflow compatible variant """ |
| 1284 | + # NOTE for train, drop_rate should be 0.5 |
| 1285 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1286 | + kwargs['pad_type'] = 'same' |
| 1287 | + model = _gen_efficientnet( |
| 1288 | + 'tf_efficientnet_b6_ns', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs) |
| 1289 | + return model |
| 1290 | + |
| 1291 | + |
| 1292 | +@register_model |
| 1293 | +def tf_efficientnet_b7_ns(pretrained=False, **kwargs): |
| 1294 | + """ EfficientNet-B7 NoisyStudent. Tensorflow compatible variant """ |
| 1295 | + # NOTE for train, drop_rate should be 0.5 |
| 1296 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1297 | + kwargs['pad_type'] = 'same' |
| 1298 | + model = _gen_efficientnet( |
| 1299 | + 'tf_efficientnet_b7_ns', channel_multiplier=2.0, depth_multiplier=3.1, pretrained=pretrained, **kwargs) |
| 1300 | + return model |
| 1301 | + |
| 1302 | + |
| 1303 | +@register_model |
| 1304 | +def tf_efficientnet_l2_ns_475(pretrained=False, **kwargs): |
| 1305 | + """ EfficientNet-L2 NoisyStudent @ 475x475. Tensorflow compatible variant """ |
| 1306 | + # NOTE for train, drop_rate should be 0.5 |
| 1307 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1308 | + kwargs['pad_type'] = 'same' |
| 1309 | + model = _gen_efficientnet( |
| 1310 | + 'tf_efficientnet_l2_ns_475', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) |
| 1311 | + return model |
| 1312 | + |
| 1313 | + |
| 1314 | +@register_model |
| 1315 | +def tf_efficientnet_l2_ns(pretrained=False, **kwargs): |
| 1316 | + """ EfficientNet-L2 NoisyStudent. Tensorflow compatible variant """ |
| 1317 | + # NOTE for train, drop_rate should be 0.5 |
| 1318 | + kwargs['bn_eps'] = BN_EPS_TF_DEFAULT |
| 1319 | + kwargs['pad_type'] = 'same' |
| 1320 | + model = _gen_efficientnet( |
| 1321 | + 'tf_efficientnet_l2_ns', channel_multiplier=4.3, depth_multiplier=5.3, pretrained=pretrained, **kwargs) |
| 1322 | + return model |
| 1323 | + |
1169 | 1324 |
|
1170 | 1325 | @register_model
|
1171 | 1326 | def tf_efficientnet_es(pretrained=False, **kwargs):
|
|
0 commit comments