Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closest EfficientNet variants #1967

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 99 additions & 1 deletion keras_hub/src/models/efficientnet/efficientnet_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b0_ra_imagenet",
},
"efficientnet_b0_ra4_e3600_r224_imagenet": {
"metadata": {
"description": (
"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".'
),
"params": 5288548,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b0_ra4_e3600_r224_imagenet",
},
"efficientnet_b1_ft_imagenet": {
"metadata": {
"description": (
"EfficientNet B1 model fine-trained on the ImageNet 1k dataset."
"EfficientNet B1 model pre-trained on the ImageNet 1k dataset."
),
"params": 7794184,
"official_name": "EfficientNet",
Expand All @@ -26,4 +41,87 @@
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b1_ft_imagenet",
},
"efficientnet_b1_ra4_e3600_r240_imagenet": {
"metadata": {
"description": (
"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".'
),
"params": 7794184,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b1_ra4_e3600_r240_imagenet",
},
"efficientnet_b2_ra_imagenet": {
"metadata": {
"description": (
"EfficientNet B2 model pre-trained on the ImageNet 1k dataset "
"with RandAugment recipe."
),
"params": 9109994,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b2_ra_imagenet",
},
"efficientnet_b3_ra2_imagenet": {
"metadata": {
"description": (
"EfficientNet B3 model pre-trained on the ImageNet 1k dataset "
"with RandAugment2 recipe."
),
"params": 12233232,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b3_ra2_imagenet",
},
"efficientnet_b4_ra2_imagenet": {
"metadata": {
"description": (
"EfficientNet B4 model pre-trained on the ImageNet 1k dataset "
"with RandAugment2 recipe."
),
"params": 19341616,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b4_ra2_imagenet",
},
"efficientnet_b5_sw_imagenet": {
"metadata": {
"description": (
"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)."
),
"params": 30389784,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b5_sw_imagenet",
},
"efficientnet_b5_sw_ft_imagenet": {
"metadata": {
"description": (
"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)."
),
"params": 30389784,
"official_name": "EfficientNet",
"path": "efficientnet",
"model_card": "https://arxiv.org/abs/1905.11946",
},
"kaggle_handle": "kaggle://keras/efficientnet/keras/efficientnet_b5_sw_ft_imagenet",
},
}
16 changes: 16 additions & 0 deletions keras_hub/src/utils/timm/convert_efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
"width_coefficient": 1.0,
"depth_coefficient": 1.1,
},
"b2": {
"width_coefficient": 1.1,
"depth_coefficient": 1.2,
},
"b3": {
"width_coefficient": 1.2,
"depth_coefficient": 1.4,
},
"b4": {
"width_coefficient": 1.4,
"depth_coefficient": 1.8,
},
"b5": {
"width_coefficient": 1.6,
"depth_coefficient": 2.2,
},
}


Expand Down
25 changes: 23 additions & 2 deletions tools/checkpoint_conversion/convert_efficientnet_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
Convert efficientnet checkpoints.

python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b0_ra_imagenet --upload_uri kaggle://kerashub/efficientnet/keras/efficientnet_b0_ra_imagenet
--preset efficientnet_b0_ra_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b0_ra_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b1_ft_imagenet --upload_uri kaggle://kerashub/efficientnet/keras/efficientnet_b1_ft_imagenet
--preset efficientnet_b0_ra4_e3600_r224_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b0_ra4_e3600_r224_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b1_ft_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b1_ft_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b1_ra4_e3600_r240_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b1_ra4_e3600_r240_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b2_ra_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b2_ra_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b3_ra2_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b3_ra2_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b4_ra2_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b4_ra2_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b5_sw_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b5_sw_imagenet
python tools/checkpoint_conversion/convert_efficientnet_checkpoints.py \
--preset efficientnet_b5_sw_ft_imagenet --upload_uri kaggle://keras/efficientnet/keras/efficientnet_b5_sw_ft_imagenet
"""

import os
Expand All @@ -22,7 +36,14 @@

PRESET_MAP = {
"efficientnet_b0_ra_imagenet": "timm/efficientnet_b0.ra_in1k",
"efficientnet_b0_ra4_e3600_r224_imagenet": "timm/efficientnet_b0.ra4_e3600_r224_in1k",
"efficientnet_b1_ft_imagenet": "timm/efficientnet_b1.ft_in1k",
"efficientnet_b1_ra4_e3600_r240_imagenet": "timm/efficientnet_b1.ra4_e3600_r240_in1k",
"efficientnet_b2_ra_imagenet": "timm/efficientnet_b2.ra_in1k",
"efficientnet_b3_ra2_imagenet": "timm/efficientnet_b3.ra2_in1k",
"efficientnet_b4_ra2_imagenet": "timm/efficientnet_b4.ra2_in1k",
"efficientnet_b5_sw_imagenet": "timm/efficientnet_b5.sw_in12k",
"efficientnet_b5_sw_ft_imagenet": "timm/efficientnet_b5.sw_in12k_ft_in1k",
}
FLAGS = flags.FLAGS

Expand Down
Loading