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
684351b6
Commit
684351b6
authored
1 year ago
by
Manon Blanco
Browse files
Options
Downloads
Patches
Plain Diff
Remove DPIAdjusting transform
parent
0c2612fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dan/transforms.py
+1
-48
1 addition, 48 deletions
dan/transforms.py
docs/usage/train/parameters.md
+0
-8
0 additions, 8 deletions
docs/usage/train/parameters.md
with
1 addition
and
56 deletions
dan/transforms.py
+
1
−
48
View file @
684351b6
...
...
@@ -20,22 +20,6 @@ from torchvision.transforms import (
from
torchvision.transforms.functional
import
InterpolationMode
class
DPIAdjusting
:
"""
Resolution modification
"""
def
__init__
(
self
,
factor
):
self
.
factor
=
factor
def
__call__
(
self
,
x
):
w
,
h
=
x
.
size
return
x
.
resize
(
(
int
(
np
.
ceil
(
w
*
self
.
factor
)),
int
(
np
.
ceil
(
h
*
self
.
factor
))),
Image
.
BILINEAR
,
)
class
Dilation
:
"""
OCR: stroke width increasing
...
...
@@ -175,33 +159,8 @@ def get_list_augmenters(img, aug_configs, fill_value):
for
aug_config
in
aug_configs
:
if
rand
((
1
,))
>
aug_config
[
"
proba
"
]:
continue
if
aug_config
[
"
type
"
]
==
"
dpi
"
:
valid_factor
=
False
while
not
valid_factor
:
factor
=
Uniform
(
aug_config
[
"
min_factor
"
],
aug_config
[
"
max_factor
"
]
).
sample
()
valid_factor
=
not
(
(
"
max_width
"
in
aug_config
and
factor
*
img
.
size
[
0
]
>
aug_config
[
"
max_width
"
]
)
or
(
"
max_height
"
in
aug_config
and
factor
*
img
.
size
[
1
]
>
aug_config
[
"
max_height
"
]
)
or
(
"
min_width
"
in
aug_config
and
factor
*
img
.
size
[
0
]
<
aug_config
[
"
min_width
"
]
)
or
(
"
min_height
"
in
aug_config
and
factor
*
img
.
size
[
1
]
<
aug_config
[
"
min_height
"
]
)
)
augmenters
.
append
(
DPIAdjusting
(
factor
))
el
if
aug_config
[
"
type
"
]
==
"
zoom_ratio
"
:
if
aug_config
[
"
type
"
]
==
"
zoom_ratio
"
:
ratio_h
=
Uniform
(
aug_config
[
"
min_ratio_h
"
],
aug_config
[
"
max_ratio_h
"
]
).
sample
()
...
...
@@ -340,12 +299,6 @@ def aug_config(proba_use_da, p):
"
order
"
:
"
random
"
,
"
proba
"
:
proba_use_da
,
"
augmentations
"
:
[
{
"
type
"
:
"
dpi
"
,
"
proba
"
:
p
,
"
min_factor
"
:
0.75
,
"
max_factor
"
:
1
,
},
{
"
type
"
:
"
perspective
"
,
"
proba
"
:
p
,
...
...
This diff is collapsed.
Click to expand it.
docs/usage/train/parameters.md
+
0
−
8
View file @
684351b6
...
...
@@ -85,7 +85,6 @@ Augmentation transformations are applied on-the-fly during training to artificia
The following transformations are implemented in
`dan/transforms.py`
:
*
Color inversion
*
DPI adjusting
*
Dilation and erosion
*
Elastic distortion
*
Reducing interline spacing
...
...
@@ -105,13 +104,6 @@ The following configuration is used by default when using the `teklia-dan train
"
order
"
:
"
random
"
,
"
proba
"
:
0.9
,
"
augmentations
"
:
[
{
"
type
"
:
"
dpi
"
,
"
proba
"
:
0.1
,
"
min_factor
"
:
0.75
,
"
max_factor
"
:
1
,
"
preserve_ratio
"
:
True
,
},
{
"
type
"
:
"
perspective
"
,
"
proba
"
:
0.1
,
...
...
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