Update README.md with new model card content
Browse files
README.md
CHANGED
@@ -2,5 +2,109 @@
|
|
2 |
library_name: keras-hub
|
3 |
---
|
4 |
### Model Overview
|
|
|
5 |
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
library_name: keras-hub
|
3 |
---
|
4 |
### Model Overview
|
5 |
+
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.
|
6 |
|
7 |
+
We develop EfficientNets based on AutoML and Compound Scaling. In particular, we first use AutoML MNAS Mobile framework 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 EfficientNet-B7.
|
8 |
|
9 |
+
This class encapsulates the architectures for both EfficientNetV1 and EfficientNetV2. EfficientNetV2 uses Fused-MBConv Blocks and Neural Architecture Search (NAS) to make models sizes much smaller while still improving overall model quality.
|
10 |
+
|
11 |
+
This model is supported in both KerasCV and KerasHub. KerasCV will no longer be actively developed, so please try to use KerasHub.
|
12 |
+
|
13 |
+
## Links
|
14 |
+
|
15 |
+
* [EfficientNet Quickstart Notebook](https://www.kaggle.com/code/prasadsachin/efficientnet-quickstart-kerashub)
|
16 |
+
* [EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946)(ICML 2019)
|
17 |
+
* [Based on the original keras.applications EfficientNet](https://github.com/keras-team/keras/blob/master/keras/applications/efficientnet.py)
|
18 |
+
* [EfficientNetV2: Smaller Models and Faster Training](https://arxiv.org/abs/2104.00298) (ICML 2021)
|
19 |
+
* [EfficientNet API Documentation](coming soon)
|
20 |
+
* [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/)
|
21 |
+
* [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/)
|
22 |
+
|
23 |
+
|
24 |
+
## Installation
|
25 |
+
|
26 |
+
Keras and KerasHub can be installed with:
|
27 |
+
|
28 |
+
```
|
29 |
+
pip install -U -q keras-hub
|
30 |
+
pip install -U -q keras
|
31 |
+
```
|
32 |
+
|
33 |
+
Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the [Keras Getting Started](https://keras.io/getting_started/) page.
|
34 |
+
|
35 |
+
## Presets
|
36 |
+
|
37 |
+
The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
|
38 |
+
|
39 |
+
| Preset name | Parameters | Description |
|
40 |
+
|------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
41 |
+
| efficientnet_b0_ra_imagenet | 5.3M | EfficientNet B0 model pre-trained on the ImageNet 1k dataset with RandAugment recipe. |
|
42 |
+
| efficientnet_b0_ra4_e3600_r224_imagenet | 5.3M | EfficientNet B0 model pre-trained on the ImageNet 1k dataset by Ross Wightman. Trained with timm scripts using hyper-parameters inspired by the MobileNet-V4 small, mixed with go-to hparams from timm and 'ResNet Strikes Back'. |
|
43 |
+
| efficientnet_b1_ft_imagenet | 7.8M | EfficientNet B1 model fine-tuned on the ImageNet 1k dataset. |
|
44 |
+
| efficientnet_b1_ra4_e3600_r240_imagenet | 7.8M | EfficientNet B1 model pre-trained on the ImageNet 1k dataset by Ross Wightman. Trained with timm scripts using hyper-parameters inspired by the MobileNet-V4 small, mixed with go-to hparams from timm and 'ResNet Strikes Back'. |
|
45 |
+
| efficientnet_b2_ra_imagenet | 9.1M | EfficientNet B2 model pre-trained on the ImageNet 1k dataset with RandAugment recipe. |
|
46 |
+
| efficientnet_b3_ra2_imagenet | 12.2M | EfficientNet B3 model pre-trained on the ImageNet 1k dataset with RandAugment2 recipe. |
|
47 |
+
| efficientnet_b4_ra2_imagenet | 19.3M | EfficientNet B4 model pre-trained on the ImageNet 1k dataset with RandAugment2 recipe. |
|
48 |
+
| efficientnet_b5_sw_imagenet | 30.4M | EfficientNet B5 model pre-trained on the ImageNet 12k dataset by Ross Wightman. Based on Swin Transformer train / pretrain recipe with modifications (related to both DeiT and ConvNeXt recipes). |
|
49 |
+
| efficientnet_b5_sw_ft_imagenet | 30.4M | EfficientNet B5 model pre-trained on the ImageNet 12k dataset and fine-tuned on ImageNet-1k by Ross Wightman. Based on Swin Transformer train / pretrain recipe with modifications (related to both DeiT and ConvNeXt recipes). |
|
50 |
+
| efficientnet_el_ra_imagenet | 10.6M | EfficientNet-EdgeTPU Large model trained on the ImageNet 1k dataset with RandAugment recipe. |
|
51 |
+
| efficientnet_em_ra2_imagenet | 6.9M | EfficientNet-EdgeTPU Medium model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
|
52 |
+
| efficientnet_es_ra_imagenet | 5.4M | EfficientNet-EdgeTPU Small model trained on the ImageNet 1k dataset with RandAugment recipe. |
|
53 |
+
| efficientnet2_rw_m_agc_imagenet | 53.2M | EfficientNet-v2 Medium model trained on the ImageNet 1k dataset with adaptive gradient clipping. |
|
54 |
+
| efficientnet2_rw_s_ra2_imagenet | 23.9M | EfficientNet-v2 Small model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
|
55 |
+
| efficientnet2_rw_t_ra2_imagenet | 13.6M | EfficientNet-v2 Tiny model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
|
56 |
+
| efficientnet_lite0_ra_imagenet | 4.7M | EfficientNet-Lite model fine-trained on the ImageNet 1k dataset with RandAugment recipe. |
|
57 |
+
|
58 |
+
## Model card
|
59 |
+
https://arxiv.org/abs/1905.11946
|
60 |
+
|
61 |
+
## Example Usage
|
62 |
+
Load
|
63 |
+
```python
|
64 |
+
classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
|
65 |
+
"efficientnet_b0_ra_imagenet",
|
66 |
+
)
|
67 |
+
```
|
68 |
+
Predict
|
69 |
+
```python
|
70 |
+
batch_size = 1
|
71 |
+
images = keras.random.normal(shape=(batch_size, 96, 96, 3))
|
72 |
+
classifier.predict(images)
|
73 |
+
```
|
74 |
+
Train, specify `num_classes` to load randomly initialized classifier head.
|
75 |
+
```python
|
76 |
+
num_classes = 2
|
77 |
+
labels = keras.random.randint(shape=(batch_size,), minval=0, maxval=num_classes)
|
78 |
+
classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
|
79 |
+
"efficientnet_b0_ra_imagenet",
|
80 |
+
num_classes=num_classes,
|
81 |
+
)
|
82 |
+
classifier.preprocessor.image_size = (96, 96)
|
83 |
+
classifier.fit(images, labels, epochs=3)
|
84 |
+
```
|
85 |
+
|
86 |
+
## Example Usage with Hugging Face URI
|
87 |
+
|
88 |
+
Load
|
89 |
+
```python
|
90 |
+
classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
|
91 |
+
"efficientnet_b0_ra_imagenet",
|
92 |
+
)
|
93 |
+
```
|
94 |
+
Predict
|
95 |
+
```python
|
96 |
+
batch_size = 1
|
97 |
+
images = keras.random.normal(shape=(batch_size, 96, 96, 3))
|
98 |
+
classifier.predict(images)
|
99 |
+
```
|
100 |
+
Train, specify `num_classes` to load randomly initialized classifier head.
|
101 |
+
```python
|
102 |
+
num_classes = 2
|
103 |
+
labels = keras.random.randint(shape=(batch_size,), minval=0, maxval=num_classes)
|
104 |
+
classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
|
105 |
+
"efficientnet_b0_ra_imagenet",
|
106 |
+
num_classes=num_classes,
|
107 |
+
)
|
108 |
+
classifier.preprocessor.image_size = (96, 96)
|
109 |
+
classifier.fit(images, labels, epochs=3)
|
110 |
+
```
|