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
5f3fc3d8
Commit
5f3fc3d8
authored
3 years ago
by
Chaza Abdelwahab
Browse files
Options
Downloads
Patches
Plain Diff
tested changes
parent
5d328548
No related branches found
Branches containing commit
No related tags found
1 merge request
!21
Draft: Resolve "support getting a certain element type's transcriptions and not just a page's"
Pipeline
#74325
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
+14
-4
14 additions, 4 deletions
kaldi_data_generator/main.py
with
14 additions
and
4 deletions
kaldi_data_generator/main.py
+
14
−
4
View file @
5f3fc3d8
...
...
@@ -38,7 +38,6 @@ MANUAL = "manual"
TEXT_LINE
=
"
text_line
"
WHITE
=
255
DEFAULT_RESCALE
=
1.0
ROTATION_CLASSES_TO_ANGLES
=
{
"
rotate_0
"
:
0
,
"
rotate_left_90
"
:
90
,
...
...
@@ -105,6 +104,7 @@ class HTRDataGenerator:
self
.
max_deskew_angle
=
max_deskew_angle
self
.
skew_angle
=
skew_angle
self
.
should_rotate
=
should_rotate
if
scale_x
or
scale_y_top
or
scale_y_bottom
:
self
.
should_resize_polygons
=
True
# use 1.0 as default - no resize, if not specified
...
...
@@ -504,13 +504,16 @@ class HTRDataGenerator:
logger
.
debug
(
f
"
Page
{
page_id
}
"
)
self
.
extract_lines
(
page_id
,
image_data
)
def
run_volumes
(
self
,
volume_ids
:
list
):
def
run_volumes
(
self
,
volume_ids
:
list
,
element_type
):
for
volume_id
in
tqdm
.
tqdm
(
volume_ids
):
logger
.
info
(
f
"
Volume
{
volume_id
}
"
)
pages
=
[
page
for
page
in
self
.
api_client
.
cached_paginate
(
"
ListElementChildren
"
,
id
=
volume_id
,
recursive
=
True
,
type
=
"
page
"
"
ListElementChildren
"
,
id
=
volume_id
,
recursive
=
True
,
type
=
element_type
,
)
]
self
.
run_pages
(
pages
)
...
...
@@ -809,6 +812,13 @@ def create_parser():
help
=
"
Cache dir where to save the full size downloaded images. Change it to force redownload.
"
,
)
parser
.
add_argument
(
"
--element_type
"
,
type
=
str
,
default
=
"
page
"
,
help
=
"
The type of the element from which you want to extract the transcriptions
"
,
)
return
parser
...
...
@@ -849,7 +859,7 @@ def main():
if
args
.
pages
:
data_generator
.
run_pages
(
args
.
pages
)
if
args
.
volumes
:
data_generator
.
run_volumes
(
args
.
volumes
)
data_generator
.
run_volumes
(
args
.
volumes
,
args
.
element_type
)
if
args
.
folders
:
data_generator
.
run_folders
(
args
.
folders
,
args
.
volume_type
)
if
args
.
corpora
:
...
...
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