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
c6605d2e
Commit
c6605d2e
authored
1 year ago
by
Mélodie Boillet
Committed by
Yoann Schneider
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused utils functions
parent
8b184a11
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!153
Remove unused utils functions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dan/utils.py
+0
-54
0 additions, 54 deletions
dan/utils.py
with
0 additions
and
54 deletions
dan/utils.py
+
0
−
54
View file @
c6605d2e
...
...
@@ -4,16 +4,6 @@ import numpy as np
import
torch
from
torch.distributions.uniform
import
Uniform
# Layout string to token
SEM_MATCHING_TOKENS_STR
=
{
"
INTITULE
"
:
"
ⓘ
"
,
"
DATE
"
:
"
ⓓ
"
,
"
COTE_SERIE
"
:
"
ⓢ
"
,
"
ANALYSE_COMPL
"
:
"
ⓒ
"
,
"
PRECISIONS_SUR_COTE
"
:
"
ⓟ
"
,
"
COTE_ARTICLE
"
:
"
ⓐ
"
,
}
# Layout begin-token to end-token
SEM_MATCHING_TOKENS
=
{
"
ⓘ
"
:
"
Ⓘ
"
,
"
ⓓ
"
:
"
Ⓓ
"
,
"
ⓢ
"
:
"
Ⓢ
"
,
"
ⓒ
"
:
"
Ⓒ
"
,
"
ⓟ
"
:
"
Ⓟ
"
,
"
ⓐ
"
:
"
Ⓐ
"
}
...
...
@@ -57,20 +47,6 @@ def pad_sequences_1D(data, padding_value):
return
padded_data
def
resize_max
(
img
,
max_width
=
None
,
max_height
=
None
):
if
max_width
is
not
None
and
img
.
shape
[
1
]
>
max_width
:
ratio
=
max_width
/
img
.
shape
[
1
]
new_h
=
int
(
np
.
floor
(
ratio
*
img
.
shape
[
0
]))
new_w
=
int
(
np
.
floor
(
ratio
*
img
.
shape
[
1
]))
img
=
cv2
.
resize
(
img
,
(
new_w
,
new_h
),
interpolation
=
cv2
.
INTER_LINEAR
)
if
max_height
is
not
None
and
img
.
shape
[
0
]
>
max_height
:
ratio
=
max_height
/
img
.
shape
[
0
]
new_h
=
int
(
np
.
floor
(
ratio
*
img
.
shape
[
0
]))
new_w
=
int
(
np
.
floor
(
ratio
*
img
.
shape
[
1
]))
img
=
cv2
.
resize
(
img
,
(
new_w
,
new_h
),
interpolation
=
cv2
.
INTER_LINEAR
)
return
img
def
pad_images
(
data
,
padding_value
,
padding_mode
=
"
br
"
):
"""
data: list of numpy array
...
...
@@ -157,36 +133,6 @@ def pad_image(
return
output
def
pad_image_width_right
(
img
,
new_width
,
padding_value
):
"""
Pad img to right side with padding value to reach new_width as width
"""
h
,
w
,
c
=
img
.
shape
pad_width
=
max
((
new_width
-
w
),
0
)
pad_right
=
np
.
ones
((
h
,
pad_width
,
c
),
dtype
=
img
.
dtype
)
*
padding_value
img
=
np
.
concatenate
([
img
,
pad_right
],
axis
=
1
)
return
img
def
pad_image_width_random
(
img
,
new_width
,
padding_value
,
max_pad_left_ratio
=
1
):
"""
Randomly pad img to left and right sides with padding value to reach new_width as width
"""
h
,
w
,
c
=
img
.
shape
pad_width
=
max
((
new_width
-
w
),
0
)
max_pad_left
=
int
(
max_pad_left_ratio
*
pad_width
)
pad_left
=
(
randint
(
0
,
min
(
pad_width
,
max_pad_left
))
if
pad_width
!=
0
and
max_pad_left
>
0
else
0
)
pad_right
=
pad_width
-
pad_left
pad_left
=
np
.
ones
((
h
,
pad_left
,
c
),
dtype
=
img
.
dtype
)
*
padding_value
pad_right
=
np
.
ones
((
h
,
pad_right
,
c
),
dtype
=
img
.
dtype
)
*
padding_value
img
=
np
.
concatenate
([
pad_left
,
img
,
pad_right
],
axis
=
1
)
return
img
def
read_image
(
filename
,
scale
=
1.0
):
"""
Read image and rescale it
...
...
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