Skip to content
Closed
Show file tree
Hide file tree
Changes from 17 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
2 changes: 1 addition & 1 deletion docs/source/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Flax), PyTorch, and/or TensorFlow.
| LayoutLMv2 | ✅ | ✅ | ✅ | ❌ | ❌ |
| LayoutLMv3 | ✅ | ✅ | ✅ | ✅ | ❌ |
| LED | ✅ | ✅ | ✅ | ✅ | ❌ |
| LeViT | ❌ | ❌ | ✅ | | ❌ |
| LeViT | ❌ | ❌ | ✅ | | ❌ |
| LiLT | ❌ | ❌ | ✅ | ❌ | ❌ |
| Longformer | ✅ | ✅ | ✅ | ✅ | ❌ |
| LongT5 | ❌ | ❌ | ✅ | ❌ | ✅ |
Expand Down
3 changes: 2 additions & 1 deletion docs/source/en/model_doc/levit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Tips:
- You can check out demo notebooks regarding inference as well as fine-tuning on custom data [here](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer)
(you can just replace [`ViTFeatureExtractor`] by [`LevitFeatureExtractor`] and [`ViTForImageClassification`] by [`LevitForImageClassification`] or [`LevitForImageClassificationWithTeacher`]).

This model was contributed by [anugunj](https://huggingface.co/anugunj). The original code can be found [here](https://github.com/facebookresearch/LeViT).
This model was contributed by [anugunj](https://huggingface.co/anugunj). The TensorFlow version was contributed by
[Aritra Roy Gosthipaty](https://huggingface.co/ariG23498). The original code can be found [here](https://github.com/facebookresearch/LeViT).


## LevitConfig
Expand Down
16 changes: 16 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,15 @@
]
)
_import_structure["models.led"].extend(["TFLEDForConditionalGeneration", "TFLEDModel", "TFLEDPreTrainedModel"])
_import_structure["models.levit"].extend(
[
"TF_LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFLevitForImageClassification",
"TFLevitForImageClassificationWithTeacher",
"TFLevitModel",
"TFLevitPreTrainedModel",
]
)
_import_structure["models.longformer"].extend(
[
"TF_LONGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
Expand Down Expand Up @@ -5472,6 +5481,13 @@
TFLayoutLMv3PreTrainedModel,
)
from .models.led import TFLEDForConditionalGeneration, TFLEDModel, TFLEDPreTrainedModel
from .models.levit import (
TF_LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
TFLevitForImageClassification,
TFLevitForImageClassificationWithTeacher,
TFLevitModel,
TFLevitPreTrainedModel,
)
from .models.longformer import (
TF_LONGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
TFLongformerForMaskedLM,
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/modeling_tf_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
("layoutlm", "TFLayoutLMModel"),
("layoutlmv3", "TFLayoutLMv3Model"),
("led", "TFLEDModel"),
("levit", "TFLevitModel"),
("longformer", "TFLongformerModel"),
("lxmert", "TFLxmertModel"),
("marian", "TFMarianModel"),
Expand Down
36 changes: 35 additions & 1 deletion src/transformers/models/levit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_torch_available,
is_vision_available,
)


_import_structure = {"configuration_levit": ["LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LevitConfig", "LevitOnnxConfig"]}
Expand Down Expand Up @@ -45,6 +51,20 @@
"LevitPreTrainedModel",
]

try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_levit"] = [
"TF_LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
"TFLevitForImageClassification",
"TFLevitForImageClassificationWithTeacher",
"TFLevitModel",
"TFLevitPreTrainedModel",
]


if TYPE_CHECKING:
from .configuration_levit import LEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, LevitConfig, LevitOnnxConfig
Expand All @@ -71,6 +91,20 @@
LevitModel,
LevitPreTrainedModel,
)

try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_levit import (
TF_LEVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
TFLevitForImageClassification,
TFLevitForImageClassificationWithTeacher,
TFLevitModel,
TFLevitPreTrainedModel,
)
else:
import sys

Expand Down
Loading