Unverified Commit 22edb68d authored by NielsRogge's avatar NielsRogge Committed by GitHub
Browse files

Squash commits (#17981)


Co-authored-by: default avatarNiels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
parent f6814372
...@@ -90,6 +90,7 @@ Ready-made configurations include the following architectures: ...@@ -90,6 +90,7 @@ Ready-made configurations include the following architectures:
- XLM - XLM
- XLM-RoBERTa - XLM-RoBERTa
- XLM-RoBERTa-XL - XLM-RoBERTa-XL
- YOLOS
In the next two sections, we'll show you how to: In the next two sections, we'll show you how to:
......
...@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING ...@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
_import_structure = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig"]} _import_structure = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]}
try: try:
if not is_vision_available(): if not is_vision_available():
...@@ -45,7 +45,7 @@ else: ...@@ -45,7 +45,7 @@ else:
if TYPE_CHECKING: if TYPE_CHECKING:
from .configuration_yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig from .configuration_yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig, YolosOnnxConfig
try: try:
if not is_vision_available(): if not is_vision_available():
......
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
# limitations under the License. # limitations under the License.
""" YOLOS model configuration""" """ YOLOS model configuration"""
from collections import OrderedDict
from typing import Mapping
from packaging import version
from ...configuration_utils import PretrainedConfig from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging from ...utils import logging
...@@ -151,3 +157,24 @@ class YolosConfig(PretrainedConfig): ...@@ -151,3 +157,24 @@ class YolosConfig(PretrainedConfig):
self.bbox_loss_coefficient = bbox_loss_coefficient self.bbox_loss_coefficient = bbox_loss_coefficient
self.giou_loss_coefficient = giou_loss_coefficient self.giou_loss_coefficient = giou_loss_coefficient
self.eos_coefficient = eos_coefficient self.eos_coefficient = eos_coefficient
class YolosOnnxConfig(OnnxConfig):
torch_onnx_minimum_version = version.parse("1.11")
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
return OrderedDict(
[
("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
]
)
@property
def atol_for_validation(self) -> float:
return 1e-4
@property
def default_onnx_opset(self) -> int:
return 12
...@@ -452,6 +452,11 @@ class FeaturesManager: ...@@ -452,6 +452,11 @@ class FeaturesManager:
"question-answering", "question-answering",
onnx_config_cls="models.xlm_roberta.XLMRobertaOnnxConfig", onnx_config_cls="models.xlm_roberta.XLMRobertaOnnxConfig",
), ),
"yolos": supported_features_mapping(
"default",
"object-detection",
onnx_config_cls="models.yolos.YolosOnnxConfig",
),
} }
AVAILABLE_FEATURES = sorted(reduce(lambda s1, s2: s1 | s2, (v.keys() for v in _SUPPORTED_MODEL_TYPE.values()))) AVAILABLE_FEATURES = sorted(reduce(lambda s1, s2: s1 | s2, (v.keys() for v in _SUPPORTED_MODEL_TYPE.values())))
......
...@@ -202,6 +202,7 @@ PYTORCH_EXPORT_MODELS = { ...@@ -202,6 +202,7 @@ PYTORCH_EXPORT_MODELS = {
("data2vec-text", "facebook/data2vec-text-base"), ("data2vec-text", "facebook/data2vec-text-base"),
("perceiver", "deepmind/language-perceiver", ("masked-lm", "sequence-classification")), ("perceiver", "deepmind/language-perceiver", ("masked-lm", "sequence-classification")),
("perceiver", "deepmind/vision-perceiver-conv", ("image-classification",)), ("perceiver", "deepmind/vision-perceiver-conv", ("image-classification",)),
("yolos", "hustvl/yolos-tiny"),
} }
PYTORCH_EXPORT_WITH_PAST_MODELS = { PYTORCH_EXPORT_WITH_PAST_MODELS = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment