Image Classification
KerasHub
Divyasreepat commited on
Commit
2cb4465
·
verified ·
1 Parent(s): 3ac1db7

Update README.md with new model card content

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md CHANGED
@@ -6,5 +6,109 @@ tags:
6
  pipeline_tag: image-classification
7
  ---
8
  ### Model Overview
 
9
 
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  pipeline_tag: image-classification
7
  ---
8
  ### Model Overview
9
+ 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.
10
 
11
+ 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.
12
 
13
+ 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.
14
+
15
+ This model is supported in both KerasCV and KerasHub. KerasCV will no longer be actively developed, so please try to use KerasHub.
16
+
17
+ ## Links
18
+
19
+ * [EfficientNet Quickstart Notebook](https://www.kaggle.com/code/prasadsachin/efficientnet-quickstart-kerashub)
20
+ * [EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946)(ICML 2019)
21
+ * [Based on the original keras.applications EfficientNet](https://github.com/keras-team/keras/blob/master/keras/applications/efficientnet.py)
22
+ * [EfficientNetV2: Smaller Models and Faster Training](https://arxiv.org/abs/2104.00298) (ICML 2021)
23
+ * [EfficientNet API Documentation](coming soon)
24
+ * [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/)
25
+ * [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/)
26
+
27
+
28
+ ## Installation
29
+
30
+ Keras and KerasHub can be installed with:
31
+
32
+ ```
33
+ pip install -U -q keras-hub
34
+ pip install -U -q keras
35
+ ```
36
+
37
+ 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.
38
+
39
+ ## Presets
40
+
41
+ The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
42
+
43
+ | Preset name | Parameters | Description |
44
+ |------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
45
+ | efficientnet_b0_ra_imagenet | 5.3M | EfficientNet B0 model pre-trained on the ImageNet 1k dataset with RandAugment recipe. |
46
+ | 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'. |
47
+ | efficientnet_b1_ft_imagenet | 7.8M | EfficientNet B1 model fine-tuned on the ImageNet 1k dataset. |
48
+ | 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'. |
49
+ | efficientnet_b2_ra_imagenet | 9.1M | EfficientNet B2 model pre-trained on the ImageNet 1k dataset with RandAugment recipe. |
50
+ | efficientnet_b3_ra2_imagenet | 12.2M | EfficientNet B3 model pre-trained on the ImageNet 1k dataset with RandAugment2 recipe. |
51
+ | efficientnet_b4_ra2_imagenet | 19.3M | EfficientNet B4 model pre-trained on the ImageNet 1k dataset with RandAugment2 recipe. |
52
+ | 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). |
53
+ | 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). |
54
+ | efficientnet_el_ra_imagenet | 10.6M | EfficientNet-EdgeTPU Large model trained on the ImageNet 1k dataset with RandAugment recipe. |
55
+ | efficientnet_em_ra2_imagenet | 6.9M | EfficientNet-EdgeTPU Medium model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
56
+ | efficientnet_es_ra_imagenet | 5.4M | EfficientNet-EdgeTPU Small model trained on the ImageNet 1k dataset with RandAugment recipe. |
57
+ | efficientnet2_rw_m_agc_imagenet | 53.2M | EfficientNet-v2 Medium model trained on the ImageNet 1k dataset with adaptive gradient clipping. |
58
+ | efficientnet2_rw_s_ra2_imagenet | 23.9M | EfficientNet-v2 Small model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
59
+ | efficientnet2_rw_t_ra2_imagenet | 13.6M | EfficientNet-v2 Tiny model trained on the ImageNet 1k dataset with RandAugment2 recipe. |
60
+ | efficientnet_lite0_ra_imagenet | 4.7M | EfficientNet-Lite model fine-trained on the ImageNet 1k dataset with RandAugment recipe. |
61
+
62
+ ## Model card
63
+ https://arxiv.org/abs/1905.11946
64
+
65
+ ## Example Usage
66
+ Load
67
+ ```python
68
+ classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
69
+ "efficientnet_b0_ra_imagenet",
70
+ )
71
+ ```
72
+ Predict
73
+ ```python
74
+ batch_size = 1
75
+ images = keras.random.normal(shape=(batch_size, 96, 96, 3))
76
+ classifier.predict(images)
77
+ ```
78
+ Train, specify `num_classes` to load randomly initialized classifier head.
79
+ ```python
80
+ num_classes = 2
81
+ labels = keras.random.randint(shape=(batch_size,), minval=0, maxval=num_classes)
82
+ classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
83
+ "efficientnet_b0_ra_imagenet",
84
+ num_classes=num_classes,
85
+ )
86
+ classifier.preprocessor.image_size = (96, 96)
87
+ classifier.fit(images, labels, epochs=3)
88
+ ```
89
+
90
+ ## Example Usage with Hugging Face URI
91
+
92
+ Load
93
+ ```python
94
+ classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
95
+ "efficientnet_b0_ra_imagenet",
96
+ )
97
+ ```
98
+ Predict
99
+ ```python
100
+ batch_size = 1
101
+ images = keras.random.normal(shape=(batch_size, 96, 96, 3))
102
+ classifier.predict(images)
103
+ ```
104
+ Train, specify `num_classes` to load randomly initialized classifier head.
105
+ ```python
106
+ num_classes = 2
107
+ labels = keras.random.randint(shape=(batch_size,), minval=0, maxval=num_classes)
108
+ classifier = keras_hub.models.EfficientNetImageClassifier.from_preset(
109
+ "efficientnet_b0_ra_imagenet",
110
+ num_classes=num_classes,
111
+ )
112
+ classifier.preprocessor.image_size = (96, 96)
113
+ classifier.fit(images, labels, epochs=3)
114
+ ```