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
Merge requests
!11
Implement extraction command
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement extraction command
implement-extraction-command
into
main
Overview
1
Commits
12
Pipelines
0
Changes
1
Merged
Yoann Schneider
requested to merge
implement-extraction-command
into
main
2 years ago
Overview
1
Commits
12
Pipelines
0
Changes
1
Expand
Requires
!9 (merged)
Closes
#9 (closed)
0
0
Merge request reports
Viewing commit
99285091
Prev
Next
Show latest version
1 file
+
0
−
35
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
99285091
remove Datasets folder
· 99285091
Yoann Schneider
authored
2 years ago
Datasets/dataset_formatters/utils_dataset.py deleted
100644 → 0
+
0
−
35
Options
import
re
import
random
import
cv2
import
json
random
.
seed
(
42
)
def
natural_sort
(
l
):
convert
=
lambda
text
:
int
(
text
)
if
text
.
isdigit
()
else
text
.
lower
()
alphanum_key
=
lambda
key
:
[
convert
(
c
)
for
c
in
re
.
split
(
'
([0-9]+)
'
,
key
)]
return
sorted
(
l
,
key
=
alphanum_key
)
def
assign_random_split
(
train_prob
,
val_prob
):
"""
assuming train_prob + val_prob + test_prob = 1
"""
prob
=
random
.
random
()
if
prob
<=
train_prob
:
return
"
train
"
elif
prob
<=
train_prob
+
val_prob
:
return
"
val
"
else
:
return
"
test
"
def
save_text
(
path
,
text
):
with
open
(
path
,
'
w
'
)
as
f
:
f
.
write
(
text
)
def
save_image
(
path
,
image
):
cv2
.
imwrite
(
path
,
cv2
.
cvtColor
(
image
,
cv2
.
COLOR_BGR2RGB
))
def
save_json
(
path
,
dict
):
with
open
(
path
,
"
w
"
)
as
outfile
:
json
.
dump
(
dict
,
outfile
,
indent
=
4
)
\ No newline at end of file
Loading