Skip to content

Commit

Permalink
add new model-like
Browse files Browse the repository at this point in the history
  • Loading branch information
younesbelkada committed Dec 14, 2023
1 parent 3060899 commit 8ee6712
Show file tree
Hide file tree
Showing 13 changed files with 2,848 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@
title: DePlot
- local: model_doc/donut
title: Donut
- local: model_doc/efficientsam
title: EfficientSam
- local: model_doc/flava
title: FLAVA
- local: model_doc/git
Expand Down
57 changes: 57 additions & 0 deletions docs/source/en/model_doc/efficientsam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--Copyright 2023 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.
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

# EfficientSam

## Overview

The EfficientSam model was proposed in [<INSERT PAPER NAME HERE>](<INSERT PAPER LINK HERE>) by <INSERT AUTHORS HERE>.
<INSERT SHORT SUMMARY HERE>

The abstract from the paper is the following:

*<INSERT PAPER ABSTRACT HERE>*

Tips:

<INSERT TIPS ABOUT MODEL HERE>

This model was contributed by [INSERT YOUR HF USERNAME HERE](https://huggingface.co/<INSERT YOUR HF USERNAME HERE>).
The original code can be found [here](<INSERT LINK TO GITHUB REPO HERE>).


## EfficientSamConfig

[[autodoc]] EfficientSamConfig

## EfficientSamVisionConfig

[[autodoc]] EfficientSamVisionConfig

## EfficientSamMaskDecoderConfig

[[autodoc]] EfficientSamMaskDecoderConfig

## EfficientSamPromptEncoderConfig

[[autodoc]] EfficientSamPromptEncoderConfig


## EfficientSamModel

[[autodoc]] EfficientSamModel
- forward

28 changes: 28 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@
"SamPromptEncoderConfig",
"SamVisionConfig",
],
"models.efficientsam": [
"EFFICIENTSAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"EfficientSamConfig",
"EfficientSamMaskDecoderConfig",

"EfficientSamPromptEncoderConfig",
"EfficientSamVisionConfig",
],
"models.seamless_m4t": [
"SEAMLESS_M4T_PRETRAINED_CONFIG_ARCHIVE_MAP",
"SeamlessM4TConfig",
Expand Down Expand Up @@ -3085,6 +3093,13 @@
"SamPreTrainedModel",
]
)
_import_structure["models.efficientsam"].extend(
[
"EFFICIENTSAM_PRETRAINED_MODEL_ARCHIVE_LIST",
"EfficientSamModel",
"EfficientSamPreTrainedModel",
]
)
_import_structure["models.seamless_m4t"].extend(
[
"SEAMLESS_M4T_PRETRAINED_MODEL_ARCHIVE_LIST",
Expand Down Expand Up @@ -5404,6 +5419,14 @@
SamPromptEncoderConfig,
SamVisionConfig,
)
from .models.efficientsam import (
EFFICIENTSAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
EfficientSamConfig,
EfficientSamMaskDecoderConfig,

EfficientSamPromptEncoderConfig,
EfficientSamVisionConfig,
)
from .models.seamless_m4t import (
SEAMLESS_M4T_PRETRAINED_CONFIG_ARCHIVE_MAP,
SeamlessM4TConfig,
Expand Down Expand Up @@ -7433,6 +7456,11 @@
SamModel,
SamPreTrainedModel,
)
from .models.efficientsam import (
EFFICIENTSAM_PRETRAINED_MODEL_ARCHIVE_LIST,
EfficientSamModel,
EfficientSamPreTrainedModel,
)

# PyTorch model imports
from .models.seamless_m4t import (
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
roformer,
rwkv,
sam,
efficientsam,
seamless_m4t,
seamless_m4t_v2,
segformer,
Expand Down
3 changes: 3 additions & 0 deletions src/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
("roformer", "RoFormerConfig"),
("rwkv", "RwkvConfig"),
("sam", "SamConfig"),
("efficientsam", "EfficientSamConfig"),
("seamless_m4t", "SeamlessM4TConfig"),
("seamless_m4t_v2", "SeamlessM4Tv2Config"),
("segformer", "SegformerConfig"),
Expand Down Expand Up @@ -412,6 +413,7 @@
("roformer", "ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("rwkv", "RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("sam", "SAM_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("efficientsam", "EFFICIENTSAM_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("seamless_m4t", "SEAMLESS_M4T_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("seamless_m4t_v2", "SEAMLESS_M4T_V2_PRETRAINED_CONFIG_ARCHIVE_MAP"),
("segformer", "SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP"),
Expand Down Expand Up @@ -656,6 +658,7 @@
("roformer", "RoFormer"),
("rwkv", "RWKV"),
("sam", "SAM"),
("efficientsam", "EfficientEfficientSam"),
("seamless_m4t", "SeamlessM4T"),
("seamless_m4t_v2", "SeamlessM4Tv2"),
("segformer", "SegFormer"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/image_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
("regnet", "ConvNextImageProcessor"),
("resnet", "ConvNextImageProcessor"),
("sam", "SamImageProcessor"),
("efficientsam", "EfficientSamImageProcessor"),
("segformer", "SegformerImageProcessor"),
("swiftformer", "ViTImageProcessor"),
("swin", "ViTImageProcessor"),
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
("roformer", "RoFormerModel"),
("rwkv", "RwkvModel"),
("sam", "SamModel"),
("efficientsam", "EfficientSamModel"),
("seamless_m4t", "SeamlessM4TModel"),
("seamless_m4t_v2", "SeamlessM4Tv2Model"),
("segformer", "SegformerModel"),
Expand Down Expand Up @@ -1124,6 +1125,7 @@
MODEL_FOR_MASK_GENERATION_MAPPING_NAMES = OrderedDict(
[
("sam", "SamModel"),
("efficientsam", "EfficientSamModel"),
]
)

Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
("pix2struct", "Pix2StructProcessor"),
("pop2piano", "Pop2PianoProcessor"),
("sam", "SamProcessor"),
("efficientsam", "EfficientSamProcessor"),
("seamless_m4t", "SeamlessM4TProcessor"),
("sew", "Wav2Vec2Processor"),
("sew-d", "Wav2Vec2Processor"),
Expand Down
65 changes: 65 additions & 0 deletions src/transformers/models/efficientsam/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2023 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 (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
)


_import_structure = {
"configuration_efficientsam": [
"EFFICIENTSAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
"EfficientSamConfig",
"EfficientSamMaskDecoderConfig",
"EfficientSamPromptEncoderConfig",
"EfficientSamVisionConfig",
],
}


try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_efficientsam"] = [
"EFFICIENTSAM_PRETRAINED_MODEL_ARCHIVE_LIST",
"EfficientSamModel",
"EfficientSamPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_efficientsam import (
EFFICIENTSAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
EfficientSamConfig,
EfficientSamMaskDecoderConfig,
EfficientSamPromptEncoderConfig,
EfficientSamVisionConfig,
)

try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_efficientsam import EFFICIENTSAM_PRETRAINED_MODEL_ARCHIVE_LIST, EfficientSamModel, EfficientSamPreTrainedModel

else:
import sys

sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
Loading

0 comments on commit 8ee6712

Please sign in to comment.