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
6fb9efdf
Commit
6fb9efdf
authored
6 months ago
by
Yoann Schneider
Committed by
Manon Blanco
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Font parameters should only be required if we draw the attention map
parent
fb4c15d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!454
Font parameters should only be required if we draw the attention map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dan/ocr/predict/inference.py
+11
-9
11 additions, 9 deletions
dan/ocr/predict/inference.py
with
11 additions
and
9 deletions
dan/ocr/predict/inference.py
+
11
−
9
View file @
6fb9efdf
...
...
@@ -341,8 +341,6 @@ def process_batch(
image_batch
:
List
[
Path
],
dan_model
:
DAN
,
device
:
str
,
font
:
Path
,
maximum_font_size
:
int
,
output
:
Path
,
confidence_score
:
bool
,
confidence_score_levels
:
List
[
Level
],
...
...
@@ -357,6 +355,8 @@ def process_batch(
max_object_height
:
int
,
tokens
:
Dict
[
str
,
EntityType
],
start_token
:
str
,
font
:
Path
|
None
=
None
,
maximum_font_size
:
int
|
None
=
None
,
)
->
None
:
input_images
,
visu_images
,
input_sizes
=
[],
[],
[]
logger
.
info
(
"
Loading images...
"
)
...
...
@@ -436,7 +436,7 @@ def process_batch(
)
# Save gif with attention map
if
attention_map
:
if
attention_map
and
font
and
maximum_font_size
:
attentions
=
prediction
[
"
attentions
"
][
idx
]
gif_filename
=
(
f
"
{
output
}
/
{
image_path
.
stem
}
_
{
attention_map_level
.
value
}
.gif
"
...
...
@@ -538,10 +538,12 @@ def run(
dynamic_mode
=
dynamic_mode
,
)
try
:
load_font
(
font
,
maximum_font_size
)
except
OSError
:
raise
FileNotFoundError
(
f
"
The font file is missing at path
{
str
(
font
)
}
"
)
# Load font if the attention map is drawn
if
attention_map
:
try
:
load_font
(
font
,
maximum_font_size
)
except
OSError
:
raise
FileNotFoundError
(
f
"
The font file is missing at path `
{
str
(
font
)
}
`
"
)
images
=
image_dir
.
rglob
(
f
"
*
{
image_extension
}
"
)
for
image_batch
in
list_to_batches
(
images
,
n
=
batch_size
):
...
...
@@ -549,8 +551,6 @@ def run(
image_batch
,
dan_model
,
device
,
font
,
maximum_font_size
,
output
,
confidence_score
,
confidence_score_levels
,
...
...
@@ -565,4 +565,6 @@ def run(
max_object_height
,
tokens
,
start_token
,
font
,
maximum_font_size
,
)
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