Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Commits
ac977a24
Commit
ac977a24
authored
1 year ago
by
Solene Tarride
Committed by
Solene Tarride
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
c3168ed3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_prediction.py
+68
-0
68 additions, 0 deletions
tests/test_prediction.py
with
68 additions
and
0 deletions
tests/test_prediction.py
+
68
−
0
View file @
ac977a24
...
...
@@ -506,27 +506,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
"
,
...
...
@@ -546,6 +557,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
)
},
],
),
...
...
@@ -561,27 +585,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
"
,
...
...
@@ -601,6 +636,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
)
},
],
),
...
...
@@ -622,17 +670,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
...
...
@@ -674,11 +728,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
,
...
...
@@ -691,14 +749,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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment