Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Data Generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
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
Data Generator
Commits
0a628757
Commit
0a628757
authored
3 years ago
by
Martin
Browse files
Options
Downloads
Patches
Plain Diff
fix linting
parent
c5e4f26e
No related branches found
No related tags found
1 merge request
!22
Add style filter (handwritten, typewritten); support ignored_classes
Pipeline
#74328
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kaldi_data_generator/main.py
+10
-11
10 additions, 11 deletions
kaldi_data_generator/main.py
with
10 additions
and
11 deletions
kaldi_data_generator/main.py
+
10
−
11
View file @
0a628757
...
...
@@ -184,10 +184,7 @@ class HTRDataGenerator:
for
elt
in
self
.
api_client
.
cached_paginate
(
"
ListElementChildren
"
,
id
=
page_id
,
with_classes
=
True
):
elem_classes
=
[
c
for
c
in
elt
[
"
classes
"
]
if
c
[
"
state
"
]
!=
"
rejected
"
]
elem_classes
=
[
c
for
c
in
elt
[
"
classes
"
]
if
c
[
"
state
"
]
!=
"
rejected
"
]
should_accept
=
True
if
self
.
should_filter_by_class
:
...
...
@@ -218,7 +215,9 @@ class HTRDataGenerator:
found_class
=
list
(
style_counts
.
keys
())[
0
]
found_class
=
Style
(
found_class
)
else
:
raise
ValueError
(
f
"
Multiple style classes on the same element!
{
elt
[
'
id
'
]
}
-
{
elem_classes
}
"
)
raise
ValueError
(
f
"
Multiple style classes on the same element!
{
elt
[
'
id
'
]
}
-
{
elem_classes
}
"
)
if
found_class
==
self
.
style
:
accepted_zones
.
append
(
elt
[
"
zone
"
][
"
id
"
])
...
...
@@ -237,7 +236,6 @@ class HTRDataGenerator:
)
raise
e
def
_validate_transcriptions
(
self
,
page_id
:
str
,
lines
:
List
[
TranscriptionData
]):
if
not
lines
:
return
...
...
@@ -296,9 +294,8 @@ class HTRDataGenerator:
and
res
[
"
worker_version_id
"
]
not
in
self
.
accepted_worker_version_ids
):
continue
if
(
(
self
.
should_filter_by_class
or
self
.
should_filter_by_style
)
and
res
[
"
element
"
][
"
zone
"
][
"
id
"
]
not
in
accepted_zones
if
(
self
.
should_filter_by_class
or
self
.
should_filter_by_style
)
and
(
res
[
"
element
"
][
"
zone
"
][
"
id
"
]
not
in
accepted_zones
):
continue
if
res
[
"
element
"
][
"
type
"
]
!=
self
.
transcription_type
:
...
...
@@ -902,8 +899,10 @@ def main():
if
args
.
style
and
args
.
accepted_classes
:
if
any
(
c
in
args
.
accepted_classes
for
c
in
STYLE_CLASSES
):
parser
.
error
(
f
"
--style class values (
{
STYLE_CLASSES
}
) shouldn
'
t be in the accepted_classes list
"
"
if both --style and --accepted_classes are used together.
"
)
parser
.
error
(
f
"
--style class values (
{
STYLE_CLASSES
}
) shouldn
'
t be in the accepted_classes list
"
"
if both --style and --accepted_classes are used together.
"
)
logger
.
info
(
f
"
ARGS
{
args
}
\n
"
)
...
...
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