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
ded809b1
Commit
ded809b1
authored
1 year ago
by
Manon Blanco
Browse files
Options
Downloads
Patches
Plain Diff
Rename predict and evaluation functions
parent
8c0dfdeb
No related branches found
No related tags found
1 merge request
!253
Rename predict and evaluation functions
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dan/ocr/manager/training.py
+5
-5
5 additions, 5 deletions
dan/ocr/manager/training.py
dan/ocr/train.py
+1
-1
1 addition, 1 deletion
dan/ocr/train.py
with
6 additions
and
6 deletions
dan/ocr/manager/training.py
+
5
−
5
View file @
ded809b1
...
@@ -670,7 +670,7 @@ class GenericTrainingManager:
...
@@ -670,7 +670,7 @@ class GenericTrainingManager:
):
):
for
valid_set_name
in
self
.
dataset
.
valid_loaders
:
for
valid_set_name
in
self
.
dataset
.
valid_loaders
:
# evaluate set and compute metrics
# evaluate set and compute metrics
eval_values
=
self
.
e
val
u
ate
(
eval_values
=
self
.
val
id
ate
(
valid_set_name
,
mlflow_logging
=
mlflow_logging
valid_set_name
,
mlflow_logging
=
mlflow_logging
)
)
# log valid metrics in tensorboard file
# log valid metrics in tensorboard file
...
@@ -702,7 +702,7 @@ class GenericTrainingManager:
...
@@ -702,7 +702,7 @@ class GenericTrainingManager:
self
.
save_model
(
epoch
=
num_epoch
,
name
=
"
last
"
)
self
.
save_model
(
epoch
=
num_epoch
,
name
=
"
last
"
)
self
.
writer
.
flush
()
self
.
writer
.
flush
()
def
e
val
u
ate
(
self
,
set_name
,
mlflow_logging
=
False
,
**
kwargs
):
def
val
id
ate
(
self
,
set_name
,
mlflow_logging
=
False
,
**
kwargs
):
"""
"""
Main loop for validation
Main loop for validation
"""
"""
...
@@ -720,7 +720,7 @@ class GenericTrainingManager:
...
@@ -720,7 +720,7 @@ class GenericTrainingManager:
tokens
=
self
.
tokens
,
tokens
=
self
.
tokens
,
)
)
with
tqdm
(
total
=
len
(
loader
.
dataset
))
as
pbar
:
with
tqdm
(
total
=
len
(
loader
.
dataset
))
as
pbar
:
pbar
.
set_description
(
"
Evalu
ation E{}
"
.
format
(
self
.
latest_epoch
))
pbar
.
set_description
(
"
Valid
ation E{}
"
.
format
(
self
.
latest_epoch
))
with
torch
.
no_grad
():
with
torch
.
no_grad
():
# iterate over batch data
# iterate over batch data
for
ind_batch
,
batch_data
in
enumerate
(
loader
):
for
ind_batch
,
batch_data
in
enumerate
(
loader
):
...
@@ -751,7 +751,7 @@ class GenericTrainingManager:
...
@@ -751,7 +751,7 @@ class GenericTrainingManager:
)
)
return
display_values
return
display_values
def
predict
(
def
evaluate
(
self
,
custom_name
,
sets_list
,
metric_names
,
mlflow_logging
=
False
,
output
=
False
self
,
custom_name
,
sets_list
,
metric_names
,
mlflow_logging
=
False
,
output
=
False
):
):
"""
"""
...
@@ -772,7 +772,7 @@ class GenericTrainingManager:
...
@@ -772,7 +772,7 @@ class GenericTrainingManager:
)
)
with
tqdm
(
total
=
len
(
loader
.
dataset
))
as
pbar
:
with
tqdm
(
total
=
len
(
loader
.
dataset
))
as
pbar
:
pbar
.
set_description
(
"
Predic
tion
"
)
pbar
.
set_description
(
"
Evalua
tion
"
)
with
torch
.
no_grad
():
with
torch
.
no_grad
():
for
ind_batch
,
batch_data
in
enumerate
(
loader
):
for
ind_batch
,
batch_data
in
enumerate
(
loader
):
# iterates over batch data
# iterates over batch data
...
...
This diff is collapsed.
Click to expand it.
dan/ocr/train.py
+
1
−
1
View file @
ded809b1
...
@@ -50,7 +50,7 @@ def train_and_test(rank, params, mlflow_logging=False):
...
@@ -50,7 +50,7 @@ def train_and_test(rank, params, mlflow_logging=False):
metrics
=
[
"
cer
"
,
"
wer
"
,
"
wer_no_punct
"
,
"
time
"
]
metrics
=
[
"
cer
"
,
"
wer
"
,
"
wer_no_punct
"
,
"
time
"
]
for
dataset_name
in
params
[
"
dataset
"
][
"
datasets
"
]:
for
dataset_name
in
params
[
"
dataset
"
][
"
datasets
"
]:
for
set_name
in
[
"
test
"
,
"
val
"
,
"
train
"
]:
for
set_name
in
[
"
test
"
,
"
val
"
,
"
train
"
]:
model
.
predict
(
model
.
evaluate
(
"
{}-{}
"
.
format
(
dataset_name
,
set_name
),
"
{}-{}
"
.
format
(
dataset_name
,
set_name
),
[
[
(
dataset_name
,
set_name
),
(
dataset_name
,
set_name
),
...
...
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