Commit
·
7db28a3
1
Parent(s):
60c5c51
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
2 |
license: cc-by-nc-4.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
pipeline_tag: image-classification
|
3 |
+
tags:
|
4 |
+
- arxiv:2010.07611
|
5 |
+
- arxiv:2104.00298
|
6 |
license: cc-by-nc-4.0
|
7 |
---
|
8 |
+
|
9 |
+
To be clear, this model is tailored to my image and video classification tasks, not to imagenet. I built EfficientNetV2.5 to outperform the existing EfficientNet b0 to b7 and EfficientNetV2 t to xl models, whether in TensorFlow or PyTorch, in terms of top-1 accuracy, efficiency, and robustness on my datasets and benchmarks.
|
10 |
+
|
11 |
+
|
12 |
+
To change the number of classes, replace the linear classification layer.
|
13 |
+
Here's an example to convert the architecture into a training-ready model.
|
14 |
+
```bash
|
15 |
+
pip install ptflops
|
16 |
+
```
|
17 |
+
```python
|
18 |
+
from ptflops import get_model_complexity_info
|
19 |
+
import torch
|
20 |
+
import urllib.request
|
21 |
+
|
22 |
+
nclass = 3 # number of classes in your dataset
|
23 |
+
input_size = (3, 304, 304) # recommended image input size
|
24 |
+
print_layer_stats = True # prints the statistics for each layer of the model
|
25 |
+
verbose = True # prints additional info about the MAC calculation
|
26 |
+
|
27 |
+
# Download the model. Skip this step if already downloaded
|
28 |
+
base_model = "efficientnetv2.5_base_in1k"
|
29 |
+
url = f"https://huggingface.co/FredZhang7/efficientnetv2.5_rw_s/resolve/main/{base_model}.pth"
|
30 |
+
file_name = f"./{base_model}.pth"
|
31 |
+
urllib.request.urlretrieve(url, file_name)
|
32 |
+
|
33 |
+
model = torch.load(file_name)
|
34 |
+
model.classifier = torch.nn.Linear(in_features=1984, out_features=nclass, bias=True)
|
35 |
+
macs, nparams = get_model_complexity_info(model, input_size, as_strings=False, print_per_layer_stat=print_layer_stats, verbose=verbose)
|
36 |
+
traced_model = torch.jit.trace(model, example_inputs)
|
37 |
+
|
38 |
+
model_name = f'{base_model}_{"{:.2f}".format(nparams / 1e6)}M_{"{:.2f}".format(macs / 1e9)}G.pth'
|
39 |
+
traced_model.save(model_name)
|
40 |
+
|
41 |
+
# Load the training-ready model
|
42 |
+
model = torch.load(model_name)
|
43 |
+
```
|