Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
shkarupa-alex committed Dec 11, 2022
2 parents cdcbee1 + 9478aa2 commit ce74d9b
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 22 deletions.
6 changes: 4 additions & 2 deletions convert_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
'micro': 'https://drive.google.com/file/d/15kt8VOXdAH_jF77g7pEPk-ZmZF13sHRd/view?usp=sharing',
'tiny': 'https://drive.google.com/file/d/1C9lLgykooDF6CxZDFDnUqw5lEqoFgULh/view?usp=sharing',
'small': 'https://drive.google.com/file/d/1bfEJQNutyDkPHAkgYcKWhjVTT_ZnYXp4/view?usp=sharing',
'base': 'https://drive.google.com/file/d/1PFugO7dqfS-eubZi-yksM_FcYvUNjXBn/view?usp=sharing'
'base': 'https://drive.google.com/file/d/1PFugO7dqfS-eubZi-yksM_FcYvUNjXBn/view?usp=sharing',
'large': 'https://drive.google.com/file/d/1XDvFQrCkK-6QIpdLU1QrXWzjwnzNcH3E/view?usp=sharing'
}
TF_MODELS = {
'nano': tfgcvit.GCViTNano,
'micro': tfgcvit.GCViTMicro,
'tiny': tfgcvit.GCViTTiny,
'small': tfgcvit.GCViTSmall,
'base': tfgcvit.GCViTBase
'base': tfgcvit.GCViTBase,
'large': tfgcvit.GCViTLarge
}


Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tensorflow>=2.9.0
keras>=2.9.0
numpy>=1.22.4
tensorflow>=2.11.0
keras>=2.11.0
numpy>=1.21.4
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='tfgcvit',
version='2.0.2',
version='2.0.3',
description='Keras (TensorFlow v2) reimplementation of Global Context Vision Transformer models.',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from tfgcvit.model import GCViT, GCViTNano, GCViTMicro, GCViTTiny, GCViTSmall, GCViTBase
from tfgcvit.model import GCViT, GCViTNano, GCViTMicro, GCViTTiny, GCViTSmall, GCViTBase, GCViTLarge
from tfgcvit.prep import preprocess_input
2 changes: 1 addition & 1 deletion tfgcvit/block.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tensorflow as tf
from keras import initializers, layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion
from tfgcvit.drop import DropPath
from tfgcvit.mlp import MLP
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/drop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tensorflow as tf
from keras import backend, layers
from keras.utils.control_flow_util import smart_cond
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/embed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/extract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion
from .pad import SymmetricPadding
from .se import SE
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/level.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tensorflow as tf
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion
from tfgcvit.block import Block
from tfgcvit.extract import FeatExtract
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/mlp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down
11 changes: 10 additions & 1 deletion tfgcvit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
'gcvit_tiny': BASE_URL.format('2.0.0', 'tiny'),
'gcvit_small': BASE_URL.format('2.0.0', 'small'),
'gcvit_base': BASE_URL.format('2.0.0', 'base'),
'gcvit_large': BASE_URL.format('2.0.3', 'large'),
}
WEIGHT_HASHES = {
'gcvit_nano': '752926536d36707415c8b17d819fb1bfc48d22fd878edde1f622c76bfe23f690',
'gcvit_micro': 'fcea210cd00d79de3fc681ddaad965ca3601077a27db256d4aacddc1154b5517',
'gcvit_tiny': 'b55e8de5e64174619bf1ffeb11ea2d9b553ce527d6aa4370f5ade875c6e7b1f5',
'gcvit_small': '0d9755ce464c8f4eece85493697c694ea616036d41136a602204c2fddec67b1b',
'gcvit_base': 'bcf1dd6a59f2ef12b0aa657f30aef0ed67bb6d17e9e91186c03e4da651b28b10'
'gcvit_base': 'bcf1dd6a59f2ef12b0aa657f30aef0ed67bb6d17e9e91186c03e4da651b28b10',
'gcvit_large': 'ec0faee8dc7a3537d8fc64d2fdf6011cbfb468cbc37426e9596a4fdef30b475a'
}


Expand Down Expand Up @@ -202,3 +204,10 @@ def GCViTBase(model_name='gcvit_base', window_size=(7, 7, 14, 7), embed_dim=128,
return GCViT(model_name=model_name, window_size=window_size, embed_dim=embed_dim, depths=depths,
num_heads=num_heads, mlp_ratio=mlp_ratio, path_drop=path_drop, layer_scale=layer_scale,
weights=weights, **kwargs)


def GCViTLarge(model_name='gcvit_large', window_size=(7, 7, 14, 7), embed_dim=192, depths=(3, 4, 19, 5),
num_heads=(6, 12, 24, 48), mlp_ratio=2., path_drop=0.5, layer_scale=1e-5, weights='imagenet', **kwargs):
return GCViT(model_name=model_name, window_size=window_size, embed_dim=embed_dim, depths=depths,
num_heads=num_heads, mlp_ratio=mlp_ratio, path_drop=path_drop, layer_scale=layer_scale,
weights=weights, **kwargs)
2 changes: 1 addition & 1 deletion tfgcvit/norm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tensorflow as tf
import warnings
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/pad.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tensorflow as tf
from keras import backend, layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable


@register_keras_serializable(package='TFGCVit')
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/reduce.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keras import layers, models
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion
from tfgcvit.norm import LayerNorm
from tfgcvit.se import SE
Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/se.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from keras import layers
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down
3 changes: 2 additions & 1 deletion tfgcvit/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
(tfgcvit.GCViTMicro, 224, 512),
(tfgcvit.GCViTTiny, 224, 512),
(tfgcvit.GCViTSmall, 224, 768),
(tfgcvit.GCViTBase, 224, 1024)
(tfgcvit.GCViTBase, 224, 1024),
(tfgcvit.GCViTLarge, 224, 1536)
]


Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tensorflow as tf
from keras import layers
from keras.testing_infra import test_combinations
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from tfgcvit.block import Block
from testing_utils import layer_multi_io_test

Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/tests/test_winatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tensorflow as tf
from keras import layers
from keras.testing_infra import test_combinations
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from tfgcvit.winatt import WindowAttention
from testing_utils import layer_multi_io_test

Expand Down
2 changes: 1 addition & 1 deletion tfgcvit/winatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tensorflow as tf
from keras import initializers, layers
from keras.utils.control_flow_util import smart_cond
from keras.utils.generic_utils import register_keras_serializable
from keras.saving.object_registration import register_keras_serializable
from keras.utils.tf_utils import shape_type_conversion


Expand Down

0 comments on commit ce74d9b

Please sign in to comment.