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
9c5acca0
Unverified
Commit
9c5acca0
authored
Aug 31, 2023
by
Younes Belkada
Committed by
GitHub
Aug 31, 2023
Browse files
[`InstructBlip`] FINAL Fix instructblip test (#25887)
fix instructblip test
parent
2be8a909
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
tests/models/instructblip/test_modeling_instructblip.py
tests/models/instructblip/test_modeling_instructblip.py
+3
-3
No files found.
tests/models/instructblip/test_modeling_instructblip.py
View file @
9c5acca0
...
@@ -538,7 +538,7 @@ class InstructBlipModelIntegrationTest(unittest.TestCase):
...
@@ -538,7 +538,7 @@ class InstructBlipModelIntegrationTest(unittest.TestCase):
logits
=
model
(
**
inputs
).
logits
logits
=
model
(
**
inputs
).
logits
expected_slice
=
torch
.
tensor
(
expected_slice
=
torch
.
tensor
(
[[
-
3.4
727
,
-
1
1.8203
,
8.3828
],
[
-
5.1
172
,
-
1
1.343
8
,
7.
7656
],
[
-
4.0
74
2
,
-
13.
468
8
,
9.1
953
]],
[[
-
3.4
902
,
-
1
2.5078
,
8.4141
],
[
-
5.1
211
,
-
1
2.132
8
,
7.
8281
],
[
-
4.0
31
2
,
-
13.
593
8
,
9.1
172
]],
device
=
torch_device
,
device
=
torch_device
,
)
)
self
.
assertTrue
(
torch
.
allclose
(
logits
[
0
,
:
3
,
:
3
].
float
(),
expected_slice
,
atol
=
1e-3
))
self
.
assertTrue
(
torch
.
allclose
(
logits
[
0
,
:
3
,
:
3
].
float
(),
expected_slice
,
atol
=
1e-3
))
...
@@ -548,12 +548,12 @@ class InstructBlipModelIntegrationTest(unittest.TestCase):
...
@@ -548,12 +548,12 @@ class InstructBlipModelIntegrationTest(unittest.TestCase):
generated_text
=
processor
.
batch_decode
(
outputs
,
skip_special_tokens
=
True
)[
0
].
strip
()
generated_text
=
processor
.
batch_decode
(
outputs
,
skip_special_tokens
=
True
)[
0
].
strip
()
# fmt: off
# fmt: off
expected_outputs
=
[
2
,
450
,
22910
,
9565
,
310
,
445
,
1967
,
338
,
393
,
263
,
767
,
338
,
13977
,
292
,
22095
,
373
,
278
,
1250
,
310
,
263
,
13328
,
20134
,
29963
,
1550
,
19500
,
37
3
,
263
,
19587
,
4272
,
11952
,
29889
]
expected_outputs
=
[
2
,
450
,
22910
,
9565
,
310
,
445
,
1967
,
338
,
393
,
263
,
767
,
338
,
13977
,
292
,
22095
,
373
,
278
,
1250
,
310
,
263
,
13328
,
20134
,
29963
,
1550
,
19500
,
162
3
,
263
,
19587
,
4272
,
11952
,
29889
]
# fmt: on
# fmt: on
self
.
assertEqual
(
outputs
[
0
].
tolist
(),
expected_outputs
)
self
.
assertEqual
(
outputs
[
0
].
tolist
(),
expected_outputs
)
self
.
assertEqual
(
self
.
assertEqual
(
generated_text
,
generated_text
,
"The unusual aspect of this image is that a man is ironing clothes on the back of a yellow SUV while driving
o
n a busy city street."
,
"The unusual aspect of this image is that a man is ironing clothes on the back of a yellow SUV while driving
dow
n a busy city street."
,
)
)
def
test_inference_flant5_xl
(
self
):
def
test_inference_flant5_xl
(
self
):
...
...
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