-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR aims to add [FLAVA](ihttps://arxiv.org/abs/2112.04482) model to the transformers repo. Following checklist delineates the list of things to be done for this PR to be complete: [x] Flava init [x] Flava base models [x] Flava layers [x] Flava Configs [x] Flava encoders [x] Flava pretraining models [ ] Flava classification/retrieval models (in progress) [x] Documentation updates (in progress) [x] Imports updates (in progress) [x] Argstring updates [x] Flava pretrained checkpoints (in progress) [ ] Flava tests [x] Flava processors (in progress) [x] Sanity check [x] Lint
- Loading branch information
Showing
19 changed files
with
5,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,93 @@ | ||
<!--Copyright 2021 The HuggingFace Team. All rights reserved. | ||
|
||
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 | ||
|
||
http://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. | ||
--> | ||
|
||
# FLAVA | ||
|
||
## Overview | ||
|
||
The FLAVA model was proposed in [FLAVA: A Foundational Language And Vision Alignment Model | ||
](https://arxiv.org/abs/2112.04482) by Amanpreet Singh, Ronghang Hu, Vedanuj Goswami, Guillaume Couairon, Wojciech Galuba, Marcus Rohrbach, and Douwe Kiela and is accepted at CVPR 2022. | ||
|
||
The paper aims at creating a single unified foundation model which can work across vision, language | ||
as well as vision-and-language multimodal tasks. | ||
|
||
The abstract from the paper is the following: | ||
|
||
State-of-the-art vision and vision-and-language models rely on large-scale visio-linguistic pretraining for obtaining good performance on a variety | ||
of downstream tasks. Generally, such models are often either cross-modal (contrastive) or multi-modal | ||
(with earlier fusion) but not both; and they often only target specific modalities or tasks. A promising | ||
direction would be to use a single holistic universal model, as a "foundation", that targets all modalities | ||
at once -- a true vision and language foundation model should be good at vision tasks, language tasks, and | ||
cross- and multi-modal vision and language tasks. We introduce FLAVA as such a model and demonstrate | ||
impressive performance on a wide range of 35 tasks spanning these target modalities. | ||
|
||
|
||
<!-- Tips: --> | ||
|
||
This model was contributed by [aps](https://huggingface.co/aps). | ||
<!-- The original code can be found [here](<INSERT LINK TO GITHUB REPO HERE>).--> | ||
|
||
|
||
## FLAVAConfig | ||
|
||
[[autodoc]] FLAVAConfig | ||
- from_configs | ||
|
||
## FLAVATextConfig | ||
|
||
[[autodoc]] FLAVATextConfig | ||
|
||
## FLAVAImageConfig | ||
|
||
[[autodoc]] FLAVAImageConfig | ||
|
||
## FLAVAMultimodalConfig | ||
|
||
[[autodoc]] FLAVAMultimodalConfig | ||
|
||
## FLAVACodebookConfig | ||
|
||
[[autodoc]] FLAVACodebookConfig | ||
|
||
## FLAVAForPretraining | ||
|
||
[[autodoc]] FLAVAForPretraining | ||
- forward | ||
|
||
## FLAVAModel | ||
|
||
[[autodoc]] FLAVAModel | ||
- forward | ||
- get_text_features | ||
- get_image_features | ||
|
||
## FLAVACodebook | ||
|
||
[[autodoc]] FLAVACodebook | ||
- forward | ||
- get_codebook_indices | ||
- get_codebook_probs | ||
|
||
## FLAVATextModel | ||
|
||
[[autodoc]] FLAVATextModel | ||
- forward | ||
|
||
## FLAVAImageModel | ||
|
||
[[autodoc]] FLAVAImageModel | ||
- forward | ||
|
||
## FLAVAMultimodalModel | ||
|
||
[[autodoc]] FLAVAMultimodalModel | ||
- forward |
This file contains 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 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 |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
electra, | ||
encoder_decoder, | ||
flaubert, | ||
flava, | ||
fnet, | ||
fsmt, | ||
funnel, | ||
|
This file contains 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 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 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 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 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 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,77 @@ | ||
# flake8: noqa | ||
# There's no way to ignore "F401 '...' imported but unused" warnings in this | ||
# module, but to preserve other warnings. So, don't check this module at all. | ||
|
||
# Copyright 2021 The HuggingFace Team. All rights reserved. | ||
# | ||
# 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 | ||
# | ||
# http://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. | ||
from typing import TYPE_CHECKING | ||
|
||
from ...utils import _LazyModule, is_torch_available, is_vision_available | ||
|
||
|
||
_import_structure = { | ||
"configuration_flava": [ | ||
"FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
"FLAVACodebookConfig", | ||
"FLAVAConfig", | ||
"FLAVAImageConfig", | ||
"FLAVAMultimodalConfig", | ||
"FLAVATextConfig", | ||
], | ||
} | ||
|
||
if is_vision_available(): | ||
_import_structure["feature_extraction_flava"] = ["FLAVACodebookFeatureExtractor", "FLAVAFeatureExtractor"] | ||
_import_structure["processing_flava"] = ["FLAVAProcessor"] | ||
|
||
if is_torch_available(): | ||
_import_structure["modeling_flava"] = [ | ||
"FLAVA_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"FLAVACodebook", | ||
"FLAVAForPretraining", | ||
"FLAVAImageModel", | ||
"FLAVAModel", | ||
"FLAVAMultimodalModel", | ||
"FLAVAPreTrainedModel", | ||
"FLAVATextModel", | ||
] | ||
|
||
if TYPE_CHECKING: | ||
from .configuration_flava import ( | ||
FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP, | ||
FLAVAConfig, | ||
FLAVAImageConfig, | ||
FLAVAMultimodalConfig, | ||
FLAVATextConfig, | ||
) | ||
|
||
if is_vision_available(): | ||
from .feature_extraction_flava import FLAVACodebookFeatureExtractor, FLAVAFeatureExtractor | ||
from .processing_flava import FLAVAProcessor | ||
|
||
if is_torch_available(): | ||
from .modeling_flava import ( | ||
FLAVA_PRETRAINED_MODEL_ARCHIVE_LIST, | ||
FLAVACodebook, | ||
FLAVAImageModel, | ||
FLAVAModel, | ||
FLAVAMultimodalModel, | ||
FLAVAPreTrainedModel, | ||
FLAVATextModel, | ||
) | ||
|
||
else: | ||
import sys | ||
|
||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) |
Oops, something went wrong.