-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Add TF port of BLIP #22090
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
Merged
Add TF port of BLIP #22090
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
98b2afd
Initial commit
Rocketknight1 e557c34
more stash commit
Rocketknight1 87767b0
Yet another stash commit
Rocketknight1 d86ec34
yet more stash commit
Rocketknight1 35deb28
Mostly working except for docs / repo consistency
Rocketknight1 0a720e4
Stop importing model list from torch file
Rocketknight1 490fc63
Add TF BLIP models to docs
Rocketknight1 6dc06bb
Add auto classes
Rocketknight1 9fd4b76
Move get_text_features and get_image_features
Rocketknight1 07f99eb
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 8cfc37d
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 1c47a2f
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 70cfe55
Update src/transformers/models/blip/modeling_tf_blip_text.py
Rocketknight1 2024f5e
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 cc1694d
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 f31e96b
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 e12e305
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 2d622f6
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 ad2c87c
Update tests/models/blip/test_modeling_tf_blip.py
Rocketknight1 6b781df
Update tests/models/blip/test_modeling_tf_blip.py
Rocketknight1 dab565b
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 ee823fc
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 d6c5869
Update tests/models/blip/test_modeling_tf_blip_text.py
Rocketknight1 cf307fa
Update src/transformers/models/blip/modeling_tf_blip_text.py
Rocketknight1 0289c28
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 c4a4b62
Use channels_last convolutions in TF (better performance + compatibil…
Rocketknight1 3a082f8
Remove _shape function
Rocketknight1 8e73e08
Move multi-line statement to one line in PT + TF
Rocketknight1 7d0f73b
Specify tf.keras.layers instead of importing from it
Rocketknight1 4ec371b
Remove test_gradient_checkpointing and empty test_training methods
Rocketknight1 561d2f8
move some multi-line statements to one line
Rocketknight1 076948b
Update docstring for generate
Rocketknight1 429c25e
Remove pruned heads set
Rocketknight1 3086257
Remove self.seq_len_dim
Rocketknight1 adb0330
Fixed issues with loss computation, should resolve some tests. Also e…
Rocketknight1 fba2385
ensure original model follows config in more cases
Rocketknight1 f6c328e
Skip the same cross-attention tests in the PT tests - didn't realize …
Rocketknight1 4d71a05
Add training args throughout the models and layers
Rocketknight1 7239db5
make fixup
Rocketknight1 09592b2
Fix docstring for inputs_embeds
Rocketknight1 d4a6fa6
Add docstring for is_decoder
Rocketknight1 60f078c
Add docstrings to text models
Rocketknight1 e6a7851
Remove redundant computation
Rocketknight1 f3062b1
Add unpack_inputs / keras_serializable
Rocketknight1 77e365e
Add modeling_tf_blip to doctests
Rocketknight1 6fff45c
Add config classes for keras serialization
Rocketknight1 34463ea
Changes to allow model porting with pt-to-tf
Rocketknight1 60b7fb7
Quick fix to decoder head and test tweaks
Rocketknight1 2a7f52d
Revert an issue with masking the embeddings outputs
Rocketknight1 d962ac6
Allow missing keys in some equivalence tests (for unused layers)
Rocketknight1 0a43f85
Add tf-pt equivalence tests back in
Rocketknight1 09095d1
Update src/transformers/models/blip/modeling_tf_blip.py
Rocketknight1 dd88c83
Update src/transformers/models/blip/modeling_tf_blip_text.py
Rocketknight1 d0fd3d4
Update src/transformers/models/blip/modeling_tf_blip_text.py
Rocketknight1 9efd53c
make fixup
Rocketknight1 afd5a9c
Refactor invert_attention_mask out into tf_utils
Rocketknight1 41fe5e1
Re-enable cross-tests on the PT side too
Rocketknight1 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
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 |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| ("bert", "TFBertModel"), | ||
| ("blenderbot", "TFBlenderbotModel"), | ||
| ("blenderbot-small", "TFBlenderbotSmallModel"), | ||
| ("blip", "TFBlipModel"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we are missing a few auto classes -- also missing on the PT side! |
||
| ("camembert", "TFCamembertModel"), | ||
| ("clip", "TFCLIPModel"), | ||
| ("convbert", "TFConvBertModel"), | ||
|
|
@@ -213,6 +214,7 @@ | |
| TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMES = OrderedDict( | ||
| [ | ||
| # Model for Zero Shot Image Classification mapping | ||
| ("blip", "TFBlipModel"), | ||
| ("clip", "TFCLIPModel"), | ||
| ] | ||
| ) | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here seem unrelated to this PR and would be better in their own PR, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair! I added them because they were needed for the
pt-to-tfcode to port the BLIP models correctly. If you'd rather I move them to a separate PR though, that's fine!