From c48894e14d6006b0a3689a8ed588ff9544b2c77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sol=C3=A8ne=20Tarride?= <starride@teklia.com> Date: Tue, 26 Sep 2023 09:16:00 +0200 Subject: [PATCH] Fix tests --- tests/test_prediction.py | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/test_prediction.py b/tests/test_prediction.py index 83c0ad9d..0b8fd978 100644 --- a/tests/test_prediction.py +++ b/tests/test_prediction.py @@ -546,27 +546,38 @@ def test_run_prediction_batch( { "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", "language_model": { +<<<<<<< HEAD <<<<<<< HEAD "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", "confidence": 0.92, ======= "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241" >>>>>>> c80c413 (Write tests for LM decoding) +======= + "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", + "confidence": 0.9226743371961854, +>>>>>>> e1ebd55 (Fix tests) }, }, { "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", "language_model": { +<<<<<<< HEAD <<<<<<< HEAD "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", "confidence": 0.88, ======= "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376" >>>>>>> c80c413 (Write tests for LM decoding) +======= + "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", + "confidence": 0.8759829104754289, +>>>>>>> e1ebd55 (Fix tests) }, }, { "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14 31", +<<<<<<< HEAD <<<<<<< HEAD "language_model": { "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14 31", @@ -586,6 +597,19 @@ def test_run_prediction_batch( "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", "language_model": {"text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère"}, >>>>>>> c80c413 (Write tests for LM decoding) +======= + "language_model": { + "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14 31", + "confidence": 0.864021797502254, + }, + }, + { + "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", + "language_model": { + "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", + "confidence": 0.8903665579889012, + }, +>>>>>>> e1ebd55 (Fix tests) }, ], ), @@ -601,27 +625,38 @@ def test_run_prediction_batch( { "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", "language_model": { +<<<<<<< HEAD <<<<<<< HEAD "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", "confidence": 0.90, ======= "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241" >>>>>>> c80c413 (Write tests for LM decoding) +======= + "text": "ⓈBellisson â’»Georges â’·91 â“P â’¸M â“€Ch â“„Plombier â“…Patron?12241", + "confidence": 0.8982517863786614, +>>>>>>> e1ebd55 (Fix tests) }, }, { "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", "language_model": { +<<<<<<< HEAD <<<<<<< HEAD "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", "confidence": 0.84, ======= "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376" >>>>>>> c80c413 (Write tests for LM decoding) +======= + "text": "ⓈTemplié â’»Marcelle â’·93 â“S â“€ch â“„E dactylo â“…18376", + "confidence": 0.8386571587822831, +>>>>>>> e1ebd55 (Fix tests) }, }, { "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14 31", +<<<<<<< HEAD <<<<<<< HEAD "language_model": { "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14331", @@ -641,6 +676,19 @@ def test_run_prediction_batch( "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", "language_model": {"text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère"}, >>>>>>> c80c413 (Write tests for LM decoding) +======= + "language_model": { + "text": "Ⓢd â’»Charles â’·11 â“P â’¸C â“€F â“„d â“…14331", + "confidence": 0.8334836549049839, + }, + }, + { + "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", + "language_model": { + "text": "ⓈNaudin â’»Marie â’·53 â“S â’¸v â“€Belle mère", + "confidence": 0.8565623750166133, + }, +>>>>>>> e1ebd55 (Fix tests) }, ], ), @@ -662,17 +710,23 @@ def test_run_prediction_batch( ), ) <<<<<<< HEAD +<<<<<<< HEAD ======= @pytest.mark.parametrize("batch_size", [1, 2]) >>>>>>> c80c413 (Write tests for LM decoding) +======= +>>>>>>> e1ebd55 (Fix tests) def test_run_prediction_language_model( image_names, language_model_weight, expected_predictions, <<<<<<< HEAD +<<<<<<< HEAD ======= batch_size, >>>>>>> c80c413 (Write tests for LM decoding) +======= +>>>>>>> e1ebd55 (Fix tests) tmp_path, ): # Make tmpdir and copy needed images inside @@ -714,11 +768,15 @@ def test_run_prediction_language_model( max_object_height=None, image_extension=".png", gpu_device=None, +<<<<<<< HEAD <<<<<<< HEAD batch_size=1, ======= batch_size=batch_size, >>>>>>> c80c413 (Write tests for LM decoding) +======= + batch_size=1, +>>>>>>> e1ebd55 (Fix tests) tokens=parse_tokens(PREDICTION_DATA_PATH / "tokens.yml"), start_token=None, use_language_model=True, @@ -731,14 +789,24 @@ def test_run_prediction_language_model( assert prediction["text"] == expected_prediction["text"] if language_model_weight > 0: + print( + prediction["language_model"]["text"], + prediction["language_model"]["confidence"], + ) assert ( prediction["language_model"]["text"] == expected_prediction["language_model"]["text"] ) <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e1ebd55 (Fix tests) assert np.isclose( prediction["language_model"]["confidence"], expected_prediction["language_model"]["confidence"], ) +<<<<<<< HEAD ======= >>>>>>> c80c413 (Write tests for LM decoding) +======= +>>>>>>> e1ebd55 (Fix tests) -- GitLab