Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
22edb68d
Unverified
Commit
22edb68d
authored
Jul 06, 2022
by
NielsRogge
Committed by
GitHub
Jul 06, 2022
Browse files
Squash commits (#17981)
Co-authored-by:
Niels Rogge
<
nielsrogge@Nielss-MacBook-Pro.local
>
parent
f6814372
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
2 deletions
+36
-2
docs/source/en/serialization.mdx
docs/source/en/serialization.mdx
+1
-0
src/transformers/models/yolos/__init__.py
src/transformers/models/yolos/__init__.py
+2
-2
src/transformers/models/yolos/configuration_yolos.py
src/transformers/models/yolos/configuration_yolos.py
+27
-0
src/transformers/onnx/features.py
src/transformers/onnx/features.py
+5
-0
tests/onnx/test_onnx_v2.py
tests/onnx/test_onnx_v2.py
+1
-0
No files found.
docs/source/en/serialization.mdx
View file @
22edb68d
...
...
@@ -90,6 +90,7 @@ Ready-made configurations include the following architectures:
- XLM
- XLM-RoBERTa
- XLM-RoBERTa-XL
- YOLOS
In the next two sections, we'
ll
show
you
how
to
:
...
...
src/transformers/models/yolos/__init__.py
View file @
22edb68d
...
...
@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING
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
:
if
not
is_vision_available
():
...
...
@@ -45,7 +45,7 @@ else:
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
:
if
not
is_vision_available
():
...
...
src/transformers/models/yolos/configuration_yolos.py
View file @
22edb68d
...
...
@@ -14,7 +14,13 @@
# limitations under the License.
""" YOLOS model configuration"""
from
collections
import
OrderedDict
from
typing
import
Mapping
from
packaging
import
version
from
...configuration_utils
import
PretrainedConfig
from
...onnx
import
OnnxConfig
from
...utils
import
logging
...
...
@@ -151,3 +157,24 @@ class YolosConfig(PretrainedConfig):
self
.
bbox_loss_coefficient
=
bbox_loss_coefficient
self
.
giou_loss_coefficient
=
giou_loss_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
src/transformers/onnx/features.py
View file @
22edb68d
...
...
@@ -452,6 +452,11 @@ class FeaturesManager:
"question-answering"
,
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
())))
...
...
tests/onnx/test_onnx_v2.py
View file @
22edb68d
...
...
@@ -202,6 +202,7 @@ PYTORCH_EXPORT_MODELS = {
(
"data2vec-text"
,
"facebook/data2vec-text-base"
),
(
"perceiver"
,
"deepmind/language-perceiver"
,
(
"masked-lm"
,
"sequence-classification"
)),
(
"perceiver"
,
"deepmind/vision-perceiver-conv"
,
(
"image-classification"
,)),
(
"yolos"
,
"hustvl/yolos-tiny"
),
}
PYTORCH_EXPORT_WITH_PAST_MODELS
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment