[Blip] Fix slow tests and doctests with correct values (#22632)
fix slow tests and doctests
This commit is contained in:
@@ -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 laying on a couch
|
two cats sleeping on a couch
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -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, 3509, 2007, 2014, 3899, 102],
|
[30522, 1037, 3861, 1997, 1037, 2450, 1998, 2014, 3899, 2006, 1996, 3509, 102],
|
||||||
)
|
)
|
||||||
|
|
||||||
@require_torch_gpu
|
@require_torch_gpu
|
||||||
@@ -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, 3509, 2007, 2014, 3899, 102],
|
[30522, 1037, 3861, 1997, 1037, 2450, 1998, 2014, 3899, 2006, 1996, 3509, 102],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_inference_vqa(self):
|
def test_inference_vqa(self):
|
||||||
@@ -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.5053]]), rtol=1e-3, atol=1e-3))
|
self.assertTrue(torch.allclose(out[0].cpu(), torch.Tensor([[0.5162]]), rtol=1e-3, atol=1e-3))
|
||||||
|
|||||||
Reference in New Issue
Block a user