Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3657748b
Unverified
Commit
3657748b
authored
Dec 21, 2023
by
amyeroberts
Committed by
GitHub
Dec 21, 2023
Browse files
Update YOLOS slow test values (#28187)
Update test values
parent
cd1350ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
tests/models/yolos/test_image_processing_yolos.py
tests/models/yolos/test_image_processing_yolos.py
+7
-7
tests/models/yolos/test_modeling_yolos.py
tests/models/yolos/test_modeling_yolos.py
+4
-4
No files found.
tests/models/yolos/test_image_processing_yolos.py
View file @
3657748b
...
...
@@ -209,14 +209,14 @@ class YolosImageProcessingTest(AnnotationFormatTestMixin, ImageProcessingTestMix
encoding
=
image_processing
(
images
=
image
,
annotations
=
target
,
return_tensors
=
"pt"
)
# verify pixel values
expected_shape
=
torch
.
Size
([
1
,
3
,
800
,
10
6
6
])
expected_shape
=
torch
.
Size
([
1
,
3
,
800
,
10
5
6
])
self
.
assertEqual
(
encoding
[
"pixel_values"
].
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
([
0.2796
,
0.3138
,
0.3481
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"pixel_values"
][
0
,
0
,
0
,
:
3
],
expected_slice
,
atol
=
1e-4
))
# verify area
expected_area
=
torch
.
tensor
([
58
87.9600
,
11250.2061
,
489353.8438
,
837122.7500
,
147967.5156
,
165732.3438
])
expected_area
=
torch
.
tensor
([
58
32.7256
,
11144.6689
,
484763.2500
,
829269.8125
,
146579.4531
,
164177.6250
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"area"
],
expected_area
))
# verify boxes
expected_boxes_shape
=
torch
.
Size
([
6
,
4
])
...
...
@@ -236,7 +236,7 @@ class YolosImageProcessingTest(AnnotationFormatTestMixin, ImageProcessingTestMix
expected_orig_size
=
torch
.
tensor
([
480
,
640
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"orig_size"
],
expected_orig_size
))
# verify size
expected_size
=
torch
.
tensor
([
800
,
10
6
6
])
expected_size
=
torch
.
tensor
([
800
,
10
5
6
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"size"
],
expected_size
))
@
slow
...
...
@@ -255,14 +255,14 @@ class YolosImageProcessingTest(AnnotationFormatTestMixin, ImageProcessingTestMix
encoding
=
image_processing
(
images
=
image
,
annotations
=
target
,
masks_path
=
masks_path
,
return_tensors
=
"pt"
)
# verify pixel values
expected_shape
=
torch
.
Size
([
1
,
3
,
800
,
10
6
6
])
expected_shape
=
torch
.
Size
([
1
,
3
,
800
,
10
5
6
])
self
.
assertEqual
(
encoding
[
"pixel_values"
].
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
([
0.2796
,
0.3138
,
0.3481
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"pixel_values"
][
0
,
0
,
0
,
:
3
],
expected_slice
,
atol
=
1e-4
))
# verify area
expected_area
=
torch
.
tensor
([
14
7979.6875
,
165527.0469
,
484638.5938
,
11292.9375
,
5879.6562
,
7634.1147
])
expected_area
=
torch
.
tensor
([
14
6591.5000
,
163974.2500
,
480092.2500
,
11187.0000
,
5824.5000
,
7562.5000
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"area"
],
expected_area
))
# verify boxes
expected_boxes_shape
=
torch
.
Size
([
6
,
4
])
...
...
@@ -279,11 +279,11 @@ class YolosImageProcessingTest(AnnotationFormatTestMixin, ImageProcessingTestMix
expected_class_labels
=
torch
.
tensor
([
17
,
17
,
63
,
75
,
75
,
93
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"class_labels"
],
expected_class_labels
))
# verify masks
expected_masks_sum
=
8
22873
expected_masks_sum
=
8
15161
self
.
assertEqual
(
encoding
[
"labels"
][
0
][
"masks"
].
sum
().
item
(),
expected_masks_sum
)
# verify orig_size
expected_orig_size
=
torch
.
tensor
([
480
,
640
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"orig_size"
],
expected_orig_size
))
# verify size
expected_size
=
torch
.
tensor
([
800
,
10
6
6
])
expected_size
=
torch
.
tensor
([
800
,
10
5
6
])
self
.
assertTrue
(
torch
.
allclose
(
encoding
[
"labels"
][
0
][
"size"
],
expected_size
))
tests/models/yolos/test_modeling_yolos.py
View file @
3657748b
...
...
@@ -352,11 +352,11 @@ class YolosModelIntegrationTest(unittest.TestCase):
self
.
assertEqual
(
outputs
.
logits
.
shape
,
expected_shape
)
expected_slice_logits
=
torch
.
tensor
(
[[
-
2
4.0248
,
-
10.3
024
,
-
14.
82
90
],
[
-
4
2.0392
,
-
16.8200
,
-
27.4334
],
[
-
27.2743
,
-
11.8154
,
-
18.7148
]],
[[
-
2
3.7219
,
-
10.3
165
,
-
14.90
83
],
[
-
4
1.5429
,
-
15.2403
,
-
24.1478
],
[
-
29.3909
,
-
12.7173
,
-
19.4650
]],
device
=
torch_device
,
)
expected_slice_boxes
=
torch
.
tensor
(
[[
0.25
59
,
0.54
55
,
0.4
706
],
[
0.2
989
,
0.7
279
,
0.
1875
],
[
0.7
73
2
,
0.40
17
,
0.4
462
]],
device
=
torch_device
[[
0.25
36
,
0.54
49
,
0.4
643
],
[
0.2
037
,
0.7
735
,
0.
3672
],
[
0.7
69
2
,
0.40
56
,
0.4
549
]],
device
=
torch_device
)
self
.
assertTrue
(
torch
.
allclose
(
outputs
.
logits
[
0
,
:
3
,
:
3
],
expected_slice_logits
,
atol
=
1e-4
))
self
.
assertTrue
(
torch
.
allclose
(
outputs
.
pred_boxes
[
0
,
:
3
,
:
3
],
expected_slice_boxes
,
atol
=
1e-4
))
...
...
@@ -365,9 +365,9 @@ class YolosModelIntegrationTest(unittest.TestCase):
results
=
image_processor
.
post_process_object_detection
(
outputs
,
threshold
=
0.3
,
target_sizes
=
[
image
.
size
[::
-
1
]]
)[
0
]
expected_scores
=
torch
.
tensor
([
0.999
4
,
0.9
790
,
0.99
64
,
0.9
972
,
0.98
61
]).
to
(
torch_device
)
expected_scores
=
torch
.
tensor
([
0.999
1
,
0.9
801
,
0.99
78
,
0.9
875
,
0.98
48
]).
to
(
torch_device
)
expected_labels
=
[
75
,
75
,
17
,
63
,
17
]
expected_slice_boxes
=
torch
.
tensor
([
33
5.0609
,
79.3848
,
375.4216
,
187.2495
]).
to
(
torch_device
)
expected_slice_boxes
=
torch
.
tensor
([
33
1.8438
,
80.5440
,
369.9546
,
188.0579
]).
to
(
torch_device
)
self
.
assertEqual
(
len
(
results
[
"scores"
]),
5
)
self
.
assertTrue
(
torch
.
allclose
(
results
[
"scores"
],
expected_scores
,
atol
=
1e-4
))
...
...
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