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
ed672864
Unverified
Commit
ed672864
authored
Apr 06, 2023
by
Younes Belkada
Committed by
GitHub
Apr 06, 2023
Browse files
[`Blip`] Fix slow tests and doctests with correct values (#22632)
fix slow tests and doctests
parent
6a02e980
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
src/transformers/models/blip/modeling_blip.py
src/transformers/models/blip/modeling_blip.py
+1
-1
tests/models/blip/test_modeling_blip.py
tests/models/blip/test_modeling_blip.py
+4
-4
No files found.
src/transformers/models/blip/modeling_blip.py
View file @
ed672864
...
@@ -1055,7 +1055,7 @@ class BlipForConditionalGeneration(BlipPreTrainedModel):
...
@@ -1055,7 +1055,7 @@ class BlipForConditionalGeneration(BlipPreTrainedModel):
>>> outputs = model.generate(**inputs)
>>> outputs = model.generate(**inputs)
>>> print(processor.decode(outputs[0], skip_special_tokens=True))
>>> print(processor.decode(outputs[0], skip_special_tokens=True))
two cats
are lay
ing on a couch
two cats
sleep
ing on a couch
```
```
"""
"""
...
...
tests/models/blip/test_modeling_blip.py
View file @
ed672864
...
@@ -1120,7 +1120,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
...
@@ -1120,7 +1120,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
# Test output
# Test output
self
.
assertEqual
(
self
.
assertEqual
(
predictions
[
0
].
tolist
(),
predictions
[
0
].
tolist
(),
[
30522
,
1037
,
3861
,
1997
,
1037
,
2450
,
3564
,
2006
,
1996
,
3
50
9
,
200
7
,
2014
,
3
89
9
,
102
],
[
30522
,
1037
,
3861
,
1997
,
1037
,
2450
,
1998
,
2014
,
3
89
9
,
200
6
,
1996
,
3
50
9
,
102
],
)
)
@
require_torch_gpu
@
require_torch_gpu
...
@@ -1148,7 +1148,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
...
@@ -1148,7 +1148,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
# Test output
# Test output
self
.
assertEqual
(
self
.
assertEqual
(
predictions
[
0
].
tolist
(),
predictions
[
0
].
tolist
(),
[
30522
,
1037
,
3861
,
1997
,
1037
,
2450
,
3564
,
2006
,
1996
,
3
50
9
,
200
7
,
2014
,
3
89
9
,
102
],
[
30522
,
1037
,
3861
,
1997
,
1037
,
2450
,
1998
,
2014
,
3
89
9
,
200
6
,
1996
,
3
50
9
,
102
],
)
)
def
test_inference_vqa
(
self
):
def
test_inference_vqa
(
self
):
...
@@ -1176,7 +1176,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
...
@@ -1176,7 +1176,7 @@ class BlipModelIntegrationTest(unittest.TestCase):
out_itm
=
model
(
**
inputs
)
out_itm
=
model
(
**
inputs
)
out
=
model
(
**
inputs
,
use_itm_head
=
False
)
out
=
model
(
**
inputs
,
use_itm_head
=
False
)
expected_scores
=
torch
.
Tensor
([[
0.
9798
,
0.0202
]])
expected_scores
=
torch
.
Tensor
([[
0.
0029
,
0.9971
]])
self
.
assertTrue
(
torch
.
allclose
(
torch
.
nn
.
Softmax
()(
out_itm
[
0
].
cpu
()),
expected_scores
,
rtol
=
1e-3
,
atol
=
1e-3
))
self
.
assertTrue
(
torch
.
allclose
(
torch
.
nn
.
Softmax
()(
out_itm
[
0
].
cpu
()),
expected_scores
,
rtol
=
1e-3
,
atol
=
1e-3
))
self
.
assertTrue
(
torch
.
allclose
(
out
[
0
].
cpu
(),
torch
.
Tensor
([[
0.5
053
]]),
rtol
=
1e-3
,
atol
=
1e-3
))
self
.
assertTrue
(
torch
.
allclose
(
out
[
0
].
cpu
(),
torch
.
Tensor
([[
0.5
162
]]),
rtol
=
1e-3
,
atol
=
1e-3
))
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