You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-35Lines changed: 34 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# EfficientNet PyTorch
2
2
3
-
### Quickstart
3
+
### Quickstart
4
4
5
5
Install with `pip install efficientnet_pytorch` and load a pretrained EfficientNet with:
6
6
```python
@@ -12,46 +12,45 @@ model = EfficientNet.from_pretrained('efficientnet-b0')
12
12
13
13
#### Update (May 14, 2020)
14
14
15
-
This update adds comprehensive comments and documentation (thanks to @workingcoder).
15
+
This update adds comprehensive comments and documentation (thanks to @workingcoder).
16
16
17
17
#### Update (January 23, 2020)
18
18
19
19
This update adds a new category of pre-trained model based on adversarial training, called _advprop_. It is important to note that the preprocessing required for the advprop pretrained models is slightly different from normal ImageNet preprocessing. As a result, by default, advprop models are not used. To load a model with advprop, use:
20
-
```
20
+
```python
21
21
model = EfficientNet.from_pretrained("efficientnet-b0", advprop=True)
22
22
```
23
23
There is also a new, large `efficientnet-b8` pretrained model that is only available in advprop form. When using these models, replace ImageNet preprocessing code as follows:
24
-
```
24
+
```python
25
25
if advprop: # for models using advprop pretrained weights
This update also addresses multiple other issues ([#115](https://github.com/lukemelas/EfficientNet-PyTorch/issues/115), [#128](https://github.com/lukemelas/EfficientNet-PyTorch/issues/128)).
31
+
This update also addresses multiple other issues ([#115](https://github.com/lukemelas/EfficientNet-PyTorch/issues/115), [#128](https://github.com/lukemelas/EfficientNet-PyTorch/issues/128)).
33
32
34
33
#### Update (October 15, 2019)
35
34
36
35
This update allows you to choose whether to use a memory-efficient Swish activation. The memory-efficient version is chosen by default, but it cannot be used when exporting using PyTorch JIT. For this purpose, we have also included a standard (export-friendly) swish activation function. To switch to the export-friendly version, simply call `model.set_swish(memory_efficient=False)` after loading your desired model. This update addresses issues [#88](https://github.com/lukemelas/EfficientNet-PyTorch/pull/88) and [#89](https://github.com/lukemelas/EfficientNet-PyTorch/pull/89).
37
36
38
37
#### Update (October 12, 2019)
39
38
40
-
This update makes the Swish activation function more memory-efficient. It also addresses pull requests [#72](https://github.com/lukemelas/EfficientNet-PyTorch/pull/72), [#73](https://github.com/lukemelas/EfficientNet-PyTorch/pull/73), [#85](https://github.com/lukemelas/EfficientNet-PyTorch/pull/85), and [#86](https://github.com/lukemelas/EfficientNet-PyTorch/pull/86). Thanks to the authors of all the pull requests!
39
+
This update makes the Swish activation function more memory-efficient. It also addresses pull requests [#72](https://github.com/lukemelas/EfficientNet-PyTorch/pull/72), [#73](https://github.com/lukemelas/EfficientNet-PyTorch/pull/73), [#85](https://github.com/lukemelas/EfficientNet-PyTorch/pull/85), and [#86](https://github.com/lukemelas/EfficientNet-PyTorch/pull/86). Thanks to the authors of all the pull requests!
41
40
42
41
#### Update (July 31, 2019)
43
42
44
43
_Upgrade the pip package with_`pip install --upgrade efficientnet-pytorch`
45
44
46
-
The B6 and B7 models are now available. Additionally, _all_ pretrained models have been updated to use AutoAugment preprocessing, which translates to better performance across the board. Usage is the same as before:
45
+
The B6 and B7 models are now available. Additionally, _all_ pretrained models have been updated to use AutoAugment preprocessing, which translates to better performance across the board. Usage is the same as before:
47
46
```python
48
47
from efficientnet_pytorch import EfficientNet
49
-
model = EfficientNet.from_pretrained('efficientnet-b7')
48
+
model = EfficientNet.from_pretrained('efficientnet-b7')
50
49
```
51
50
52
51
#### Update (June 29, 2019)
53
52
54
-
This update adds easy model exporting ([#20](https://github.com/lukemelas/EfficientNet-PyTorch/issues/20)) and feature extraction ([#38](https://github.com/lukemelas/EfficientNet-PyTorch/issues/38)).
53
+
This update adds easy model exporting ([#20](https://github.com/lukemelas/EfficientNet-PyTorch/issues/20)) and feature extraction ([#38](https://github.com/lukemelas/EfficientNet-PyTorch/issues/38)).
@@ -60,29 +59,29 @@ This update adds easy model exporting ([#20](https://github.com/lukemelas/Effici
60
59
It is also now incredibly simple to load a pretrained model with a new number of classes for transfer learning:
61
60
```python
62
61
model = EfficientNet.from_pretrained('efficientnet-b1', num_classes=23)
63
-
```
62
+
```
64
63
65
64
66
65
#### Update (June 23, 2019)
67
66
68
-
The B4 and B5 models are now available. Their usage is identical to the other models:
67
+
The B4 and B5 models are now available. Their usage is identical to the other models:
69
68
```python
70
69
from efficientnet_pytorch import EfficientNet
71
-
model = EfficientNet.from_pretrained('efficientnet-b4')
70
+
model = EfficientNet.from_pretrained('efficientnet-b4')
72
71
```
73
72
74
73
### Overview
75
-
This repository contains an op-for-op PyTorch reimplementation of [EfficientNet](https://arxiv.org/abs/1905.11946), along with pre-trained models and examples.
74
+
This repository contains an op-for-op PyTorch reimplementation of [EfficientNet](https://arxiv.org/abs/1905.11946), along with pre-trained models and examples.
76
75
77
-
The goal of this implementation is to be simple, highly extensible, and easy to integrate into your own projects. This implementation is a work in progress -- new features are currently being implemented.
76
+
The goal of this implementation is to be simple, highly extensible, and easy to integrate into your own projects. This implementation is a work in progress -- new features are currently being implemented.
78
77
79
-
At the moment, you can easily:
80
-
* Load pretrained EfficientNet models
81
-
* Use EfficientNet models for classification or feature extraction
78
+
At the moment, you can easily:
79
+
* Load pretrained EfficientNet models
80
+
* Use EfficientNet models for classification or feature extraction
82
81
* Evaluate EfficientNet models on ImageNet or your own images
83
82
84
83
_Upcoming features_: In the next few days, you will be able to:
85
-
* Train new models from scratch on ImageNet with a simple command
84
+
* Train new models from scratch on ImageNet with a simple command
86
85
* Quickly finetune an EfficientNet on your own dataset
87
86
* Export EfficientNet models for production
88
87
@@ -95,11 +94,11 @@ _Upcoming features_: In the next few days, you will be able to:
If you're new to EfficientNets, here is an explanation straight from the official TensorFlow implementation:
101
+
If you're new to EfficientNets, here is an explanation straight from the official TensorFlow implementation:
103
102
104
103
EfficientNets are a family of image classification models, which achieve state-of-the-art accuracy, yet being an order-of-magnitude smaller and faster than previous models. We develop EfficientNets based on AutoML and Compound Scaling. In particular, we first use [AutoML Mobile framework](https://ai.googleblog.com/2018/08/mnasnet-towards-automating-design-of.html) to develop a mobile-size baseline network, named as EfficientNet-B0; Then, we use the compound scaling method to scale up this baseline to obtain EfficientNet-B1 to B7.
@@ -177,7 +176,7 @@ Details about the models are below:
177
176
178
177
Below is a simple, complete example. It may also be found as a jupyter notebook in `examples/simple` or as a [Colab Notebook](https://colab.research.google.com/drive/1Jw28xZ1NJq4Cja4jLe6tJ6_F5lCzElb4).
179
178
180
-
We assume that in your current directory, there is a `img.jpg` file and a `labels_map.txt` file (ImageNet class names). These are both included in `examples/simple`.
179
+
We assume that in your current directory, there is a `img.jpg` file and a `labels_map.txt` file (ImageNet class names). These are both included in `examples/simple`.
181
180
182
181
```python
183
182
import json
@@ -210,7 +209,7 @@ for idx in torch.topk(outputs, k=5).indices.squeeze(0).tolist():
0 commit comments