14
14
from torchvision .models .mobilenetv2 import ConvBNActivation , _make_divisible
15
15
16
16
17
- __all__ = ["EfficientNet" , "efficientnet_b0" , "efficientnet_b3" ]
17
+ __all__ = ["EfficientNet" , "efficientnet_b0" , "efficientnet_b1" , "efficientnet_b2" , "efficientnet_b3" ,
18
+ "efficientnet_b4" , "efficientnet_b5" , "efficientnet_b6" , "efficientnet_b7" ]
18
19
19
20
20
21
model_urls = { # TODO: Add weights
21
- "efficientnet_b0" : None ,
22
- "efficientnet_b3" : None ,
22
+ "efficientnet_b0" : "https://download.pytorch.org/models/efficientnet_b0-lukemelas.pth" ,
23
+ "efficientnet_b1" : "https://download.pytorch.org/models/efficientnet_b1-lukemelas.pth" ,
24
+ "efficientnet_b2" : "https://download.pytorch.org/models/efficientnet_b2-lukemelas.pth" ,
25
+ "efficientnet_b3" : "https://download.pytorch.org/models/efficientnet_b3-lukemelas.pth" ,
26
+ "efficientnet_b4" : "https://download.pytorch.org/models/efficientnet_b4-lukemelas.pth" ,
27
+ "efficientnet_b5" : "https://download.pytorch.org/models/efficientnet_b5-lukemelas.pth" ,
28
+ "efficientnet_b6" : "https://download.pytorch.org/models/efficientnet_b6-lukemelas.pth" ,
29
+ "efficientnet_b7" : "https://download.pytorch.org/models/efficientnet_b7-lukemelas.pth" ,
23
30
}
24
31
25
32
@@ -256,6 +263,32 @@ def efficientnet_b0(pretrained: bool = False, progress: bool = True, **kwargs: A
256
263
return _efficientnet_model ("efficientnet_b0" , inverted_residual_setting , 0.2 , pretrained , progress , ** kwargs )
257
264
258
265
266
+ def efficientnet_b1 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
267
+ """
268
+ Constructs a EfficientNet B1 architecture from
269
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
270
+
271
+ Args:
272
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
273
+ progress (bool): If True, displays a progress bar of the download to stderr
274
+ """
275
+ inverted_residual_setting = _efficientnet_conf (width_mult = 1.0 , depth_mult = 1.1 , ** kwargs )
276
+ return _efficientnet_model ("efficientnet_b1" , inverted_residual_setting , 0.2 , pretrained , progress , ** kwargs )
277
+
278
+
279
+ def efficientnet_b2 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
280
+ """
281
+ Constructs a EfficientNet B2 architecture from
282
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
283
+
284
+ Args:
285
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
286
+ progress (bool): If True, displays a progress bar of the download to stderr
287
+ """
288
+ inverted_residual_setting = _efficientnet_conf (width_mult = 1.1 , depth_mult = 1.2 , ** kwargs )
289
+ return _efficientnet_model ("efficientnet_b2" , inverted_residual_setting , 0.3 , pretrained , progress , ** kwargs )
290
+
291
+
259
292
def efficientnet_b3 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
260
293
"""
261
294
Constructs a EfficientNet B3 architecture from
@@ -267,3 +300,55 @@ def efficientnet_b3(pretrained: bool = False, progress: bool = True, **kwargs: A
267
300
"""
268
301
inverted_residual_setting = _efficientnet_conf (width_mult = 1.2 , depth_mult = 1.4 , ** kwargs )
269
302
return _efficientnet_model ("efficientnet_b3" , inverted_residual_setting , 0.3 , pretrained , progress , ** kwargs )
303
+
304
+
305
+ def efficientnet_b4 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
306
+ """
307
+ Constructs a EfficientNet B4 architecture from
308
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
309
+
310
+ Args:
311
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
312
+ progress (bool): If True, displays a progress bar of the download to stderr
313
+ """
314
+ inverted_residual_setting = _efficientnet_conf (width_mult = 1.4 , depth_mult = 1.8 , ** kwargs )
315
+ return _efficientnet_model ("efficientnet_b4" , inverted_residual_setting , 0.4 , pretrained , progress , ** kwargs )
316
+
317
+
318
+ def efficientnet_b5 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
319
+ """
320
+ Constructs a EfficientNet B5 architecture from
321
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
322
+
323
+ Args:
324
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
325
+ progress (bool): If True, displays a progress bar of the download to stderr
326
+ """
327
+ inverted_residual_setting = _efficientnet_conf (width_mult = 1.6 , depth_mult = 2.2 , ** kwargs )
328
+ return _efficientnet_model ("efficientnet_b5" , inverted_residual_setting , 0.4 , pretrained , progress , ** kwargs )
329
+
330
+
331
+ def efficientnet_b6 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
332
+ """
333
+ Constructs a EfficientNet B6 architecture from
334
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
335
+
336
+ Args:
337
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
338
+ progress (bool): If True, displays a progress bar of the download to stderr
339
+ """
340
+ inverted_residual_setting = _efficientnet_conf (width_mult = 1.8 , depth_mult = 2.6 , ** kwargs )
341
+ return _efficientnet_model ("efficientnet_b6" , inverted_residual_setting , 0.5 , pretrained , progress , ** kwargs )
342
+
343
+
344
+ def efficientnet_b7 (pretrained : bool = False , progress : bool = True , ** kwargs : Any ) -> EfficientNet :
345
+ """
346
+ Constructs a EfficientNet B7 architecture from
347
+ `"EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" <https://arxiv.org/abs/1905.11946>`_.
348
+
349
+ Args:
350
+ pretrained (bool): If True, returns a model pre-trained on ImageNet
351
+ progress (bool): If True, displays a progress bar of the download to stderr
352
+ """
353
+ inverted_residual_setting = _efficientnet_conf (width_mult = 2.0 , depth_mult = 3.1 , ** kwargs )
354
+ return _efficientnet_model ("efficientnet_b7" , inverted_residual_setting , 0.5 , pretrained , progress , ** kwargs )
0 commit comments