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
133e3ddb
Commit
133e3ddb
authored
1 year ago
by
Marie Generali
Browse files
Options
Downloads
Plain Diff
Merge branch 'dan-temperature-scaling' of gitlab.com:teklia/atr/dan into dan-temperature-scaling
parents
2b450d52
7f9934ae
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
dan/predict/prediction.py
+8
-8
8 additions, 8 deletions
dan/predict/prediction.py
with
8 additions
and
8 deletions
dan/predict/prediction.py
+
8
−
8
View file @
133e3ddb
...
...
@@ -2,6 +2,7 @@
import
os
import
pickle
from
itertools
import
pairwise
from
pathlib
import
Path
import
cv2
...
...
@@ -351,14 +352,13 @@ def run(
index
=
[
pos
for
pos
,
char
in
enumerate
(
text
)
if
char
in
[
"
ⓝ
"
,
"
ⓟ
"
,
"
ⓓ
"
,
"
ⓡ
"
]]
# calculates scores by token
score_by_token
=
[]
for
rang
,
position
in
enumerate
(
index
[:
-
1
]):
score_by_token
.
append
(
{
"
text
"
:
f
"
{
text
[
position
:
index
[
rang
+
1
]
-
1
]
}
"
,
"
confidence_ner
"
:
f
"
{
np
.
around
(
np
.
mean
(
char_confidences
[
position
:
index
[
rang
+
1
]
-
1
]),
2
)
}
"
,
}
)
score_by_token
=
[
{
"
text
"
:
f
"
{
text
[
current
:
next_token
-
1
]
}
"
,
"
confidence_ner
"
:
f
"
{
np
.
around
(
np
.
mean
(
char_confidences
[
current
:
next_token
-
1
]),
2
)
}
"
,
}
for
current
,
next_token
in
pairwise
(
index
)
]
result
[
"
confidences
"
][
"
total
"
]
=
np
.
around
(
np
.
mean
(
char_confidences
),
2
)
result
[
"
confidences
"
][
"
by ner token
"
]
=
[]
...
...
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