-
Notifications
You must be signed in to change notification settings - Fork 305
[Mix Transformer] Add Presets for MiTB0...MiTB5 #1893
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
Merged
divyashreepathihalli
merged 23 commits into
keras-team:master
from
DavidLandup0:feature/mit_presets
Oct 9, 2024
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4dc3fff
add presets for mit
DavidLandup0 191656c
add standin paths
DavidLandup0 98bb69d
register presets in __init__.py
DavidLandup0 8d95091
Merge branch 'master' into feature/mit_presets
DavidLandup0 0c92729
fix op in overlapping patching and embedding, start adding conversion…
DavidLandup0 6638cb1
style
DavidLandup0 9a3f82d
add padding to MiT patchingandembedding
DavidLandup0 76a6dd2
update to support other presets
DavidLandup0 7b06c79
update conversin script
DavidLandup0 6e9728f
fix link for b5
DavidLandup0 7119022
add cityscapes weights
DavidLandup0 8ea5f63
update presets
DavidLandup0 0705748
update presets
DavidLandup0 eb1c236
update conversion script to make directories
DavidLandup0 fc42598
use save_preset
DavidLandup0 4274c60
change name of output dir
DavidLandup0 dc72ea7
add preprocessor flow
DavidLandup0 65f1822
api gen and add preprocessor to mits
DavidLandup0 d1bc073
merge master into feature branch
DavidLandup0 000d7d0
conform to new image classifier style
DavidLandup0 fa34f9e
format
DavidLandup0 e3c6dc6
resizing image converter -> ImageConverter
DavidLandup0 2a8ffcb
address comments
DavidLandup0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from keras_hub.src.models.mix_transformer.mix_transformer_backbone import ( | ||
| MiTBackbone, | ||
| ) | ||
| from keras_hub.src.models.mix_transformer.mix_transformer_classifier import ( | ||
| MiTImageClassifier, | ||
| ) | ||
| from keras_hub.src.models.mix_transformer.mix_transformer_presets import ( | ||
| backbone_presets, | ||
| ) | ||
| from keras_hub.src.utils.preset_utils import register_presets | ||
|
|
||
| register_presets(backbone_presets, MiTBackbone) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
keras_hub/src/models/mix_transformer/mix_transformer_classifier_preprocessor.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from keras_hub.src.api_export import keras_hub_export | ||
| from keras_hub.src.models.image_classifier_preprocessor import ( | ||
| ImageClassifierPreprocessor, | ||
| ) | ||
| from keras_hub.src.models.mix_transformer.mix_transformer_backbone import ( | ||
| MiTBackbone, | ||
| ) | ||
| from keras_hub.src.models.mix_transformer.mix_transformer_image_converter import ( | ||
| MiTImageConverter, | ||
| ) | ||
|
|
||
|
|
||
| @keras_hub_export("keras_hub.models.MiTImageClassifierPreprocessor") | ||
| class MiTImageClassifierPreprocessor(ImageClassifierPreprocessor): | ||
| backbone_cls = MiTBackbone | ||
| image_converter_cls = MiTImageConverter |
8 changes: 8 additions & 0 deletions
8
keras_hub/src/models/mix_transformer/mix_transformer_image_converter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from keras_hub.src.api_export import keras_hub_export | ||
| from keras_hub.src.layers.preprocessing.image_converter import ImageConverter | ||
| from keras_hub.src.models.mix_transformer import MiTBackbone | ||
|
|
||
|
|
||
| @keras_hub_export("keras_hub.layers.MiTImageConverter") | ||
| class MiTImageConverter(ImageConverter): | ||
| backbone_cls = MiTBackbone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
keras_hub/src/models/mix_transformer/mix_transformer_presets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| # Copyright 2024 The KerasHub Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """MiT model preset configurations.""" | ||
|
|
||
| backbone_presets_with_weights = { | ||
| "mit_b0_ade20k_512": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 8 transformer blocks." | ||
| ), | ||
| "params": 3321962, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b0_ade20k_512", | ||
| }, | ||
| "mit_b1_ade20k_512": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 8 transformer blocks." | ||
| ), | ||
| "params": 13156554, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b1_ade20k_512", | ||
| }, | ||
| "mit_b2_ade20k_512": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 16 transformer blocks." | ||
| ), | ||
| "params": 24201418, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b2_ade20k_512", | ||
| }, | ||
| "mit_b3_ade20k_512": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 28 transformer blocks." | ||
| ), | ||
| "params": 44077258, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b3_ade20k_512", | ||
| }, | ||
| "mit_b4_ade20k_512": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 41 transformer blocks." | ||
| ), | ||
| "params": 60847818, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b4_ade20k_512", | ||
| }, | ||
| "mit_b5_ade20k_640": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 52 transformer blocks." | ||
| ), | ||
| "params": 81448138, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b5_ade20k_512", | ||
| }, | ||
| "mit_b0_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 8 transformer blocks." | ||
| ), | ||
| "params": 3321962, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b0_cityscapes_1024", | ||
| }, | ||
| "mit_b1_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 8 transformer blocks." | ||
| ), | ||
| "params": 13156554, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b1_cityscapes_1024", | ||
| }, | ||
| "mit_b2_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 16 transformer blocks." | ||
| ), | ||
| "params": 24201418, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b2_cityscapes_1024", | ||
| }, | ||
| "mit_b3_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 28 transformer blocks." | ||
| ), | ||
| "params": 44077258, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b3_cityscapes_1024", | ||
| }, | ||
| "mit_b4_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 41 transformer blocks." | ||
| ), | ||
| "params": 60847818, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b4_cityscapes_1024", | ||
| }, | ||
| "mit_b5_cityscapes_1024": { | ||
| "metadata": { | ||
| "description": ( | ||
| "MiT (MixTransformer) model with 52 transformer blocks." | ||
| ), | ||
| "params": 81448138, | ||
| "official_name": "MiT", | ||
| "path": "mit", | ||
| }, | ||
| "kaggle_handle": "kaggle://kerashub/mix-transformer/keras/mit_b5_cityscapes_1024", | ||
| }, | ||
| } | ||
|
|
||
| backbone_presets = { | ||
| **backbone_presets_with_weights, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.