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
c3d2f8fe
Commit
c3d2f8fe
authored
1 year ago
by
Nolan
Committed by
Yoann Schneider
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove get_valid_fonts function
parent
22392bfd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!124
Remove get_valid_fonts function
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dan/manager/ocr.py
+0
-31
0 additions, 31 deletions
dan/manager/ocr.py
with
0 additions
and
31 deletions
dan/manager/ocr.py
+
0
−
31
View file @
c3d2f8fe
...
...
@@ -9,7 +9,6 @@ import torch
from
fontTools.ttLib
import
TTFont
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
dan
import
logger
from
dan.manager.dataset
import
DatasetManager
,
GenericDataset
,
apply_preprocessing
from
dan.ocr.utils
import
LM_str_to_ind
from
dan.utils
import
(
...
...
@@ -42,8 +41,6 @@ class OCRDatasetManager(DatasetManager):
and
self
.
params
[
"
config
"
][
"
synthetic_data
"
]
):
self
.
synthetic_data
=
self
.
params
[
"
config
"
][
"
synthetic_data
"
]
if
"
config
"
in
self
.
synthetic_data
:
self
.
synthetic_data
[
"
config
"
][
"
valid_fonts
"
]
=
self
.
get_valid_fonts
()
if
"
new_tokens
"
in
params
:
self
.
charset
=
sorted
(
...
...
@@ -104,34 +101,6 @@ class OCRDatasetManager(DatasetManager):
[
s
[
"
img
"
].
shape
[
1
]
for
s
in
self
.
train_dataset
.
samples
]
)
def
get_valid_fonts
(
self
):
"""
Select fonts that are compatible with the alphabet
"""
font_path
=
self
.
synthetic_data
[
"
font_path
"
]
alphabet
=
self
.
charset
.
copy
()
special_chars
=
[
"
\n
"
]
alphabet
=
[
char
for
char
in
alphabet
if
char
not
in
special_chars
]
valid_fonts
=
list
()
for
fold_detail
in
os
.
walk
(
font_path
):
if
fold_detail
[
2
]:
for
font_name
in
fold_detail
[
2
]:
if
"
.ttf
"
not
in
font_name
:
continue
font_path
=
os
.
path
.
join
(
fold_detail
[
0
],
font_name
)
to_add
=
True
if
alphabet
is
not
None
:
for
char
in
alphabet
:
if
not
char_in_font
(
char
,
font_path
):
to_add
=
False
break
if
to_add
:
valid_fonts
.
append
(
font_path
)
else
:
valid_fonts
.
append
(
font_path
)
logger
.
info
(
f
"
Found
{
len
(
valid_fonts
)
}
fonts.
"
)
return
valid_fonts
class
OCRDataset
(
GenericDataset
):
"""
...
...
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