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
0ce6787a
Verified
Commit
0ce6787a
authored
1 year ago
by
Mélodie Boillet
Browse files
Options
Downloads
Patches
Plain Diff
Remove list of applied data augmentations
parent
0f97e244
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dan/manager/dataset.py
+1
-1
1 addition, 1 deletion
dan/manager/dataset.py
dan/manager/ocr.py
+1
-5
1 addition, 5 deletions
dan/manager/ocr.py
dan/transforms.py
+2
-4
2 additions, 4 deletions
dan/transforms.py
with
4 additions
and
10 deletions
dan/manager/dataset.py
+
1
−
1
View file @
0ce6787a
...
...
@@ -336,7 +336,7 @@ class GenericDataset(Dataset):
for
aug
,
set_name
in
zip
(
augs
,
[
"
train
"
,
"
val
"
,
"
test
"
]):
if
aug
and
self
.
set_name
==
set_name
:
return
apply_data_augmentation
(
img
,
aug
)
return
img
,
list
()
return
img
def
get_sample_img
(
self
,
i
):
"""
...
...
This diff is collapsed.
Click to expand it.
dan/manager/ocr.py
+
1
−
5
View file @
0ce6787a
...
...
@@ -136,9 +136,7 @@ class OCRDataset(GenericDataset):
sample
=
self
.
generate_synthetic_data
(
sample
)
# Data augmentation
sample
[
"
img
"
],
sample
[
"
applied_da
"
]
=
self
.
apply_data_augmentation
(
sample
[
"
img
"
]
)
sample
[
"
img
"
]
=
self
.
apply_data_augmentation
(
sample
[
"
img
"
])
if
"
max_size
"
in
self
.
params
[
"
config
"
]
and
self
.
params
[
"
config
"
][
"
max_size
"
]:
max_ratio
=
max
(
...
...
@@ -523,7 +521,6 @@ class OCRCollateFunction:
batch_data
[
i
][
"
name
"
].
split
(
"
/
"
)[
-
1
].
split
(
"
.
"
)[
0
]
for
i
in
range
(
len
(
batch_data
))
]
applied_da
=
[
batch_data
[
i
][
"
applied_da
"
]
for
i
in
range
(
len
(
batch_data
))]
labels
=
[
batch_data
[
i
][
"
token_label
"
]
for
i
in
range
(
len
(
batch_data
))]
labels
=
pad_sequences_1D
(
labels
,
padding_value
=
self
.
label_padding_value
)
...
...
@@ -630,7 +627,6 @@ class OCRCollateFunction:
"
word_raw
"
:
word_raw
,
"
word_labels
"
:
pad_word_token
,
"
word_labels_len
"
:
word_len
,
"
applied_da
"
:
applied_da
,
}
return
formatted_batch_data
...
...
This diff is collapsed.
Click to expand it.
dan/transforms.py
+
2
−
4
View file @
0ce6787a
...
...
@@ -328,9 +328,8 @@ def apply_data_augmentation(img, da_config):
"""
Apply data augmentation strategy on input image
"""
applied_da
=
list
()
if
da_config
[
"
proba
"
]
!=
1
and
rand
()
>
da_config
[
"
proba
"
]:
return
img
,
applied_da
return
img
# Convert to PIL Image
img
=
img
[:,
:,
0
]
if
img
.
shape
[
2
]
==
1
else
img
...
...
@@ -345,12 +344,11 @@ def apply_data_augmentation(img, da_config):
for
augmenter
in
augmenters
:
img
=
augmenter
(
img
)
applied_da
.
append
(
type
(
augmenter
).
__name__
)
# convert to numpy array
img
=
np
.
array
(
img
)
img
=
np
.
expand_dims
(
img
,
axis
=
2
)
if
len
(
img
.
shape
)
==
2
else
img
return
img
,
applied_da
return
img
def
apply_transform
(
img
,
transform
):
...
...
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