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
!57
Do not force mlflow usage
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Do not force mlflow usage
train-without-mlflow
into
main
Overview
1
Commits
3
Pipelines
0
Changes
2
Merged
Yoann Schneider
requested to merge
train-without-mlflow
into
main
2 years ago
Overview
1
Commits
3
Pipelines
0
Changes
2
Expand
Closes
#29 (closed)
0
0
Merge request reports
Viewing commit
82d30655
Prev
Next
Show latest version
2 files
+
24
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Verified
82d30655
do not force mlflow
· 82d30655
Yoann Schneider
authored
2 years ago
dan/ocr/document/train.py
+
18
−
4
Options
@@ -5,20 +5,28 @@ import random
from
copy
import
deepcopy
from
pathlib
import
Path
import
mlflow
import
numpy
as
np
import
torch
import
torch.multiprocessing
as
mp
from
torch.optim
import
Adam
from
dan
import
logger
from
dan.decoder
import
GlobalHTADecoder
from
dan.manager.ocr
import
OCRDataset
,
OCRDatasetManager
from
dan.manager.training
import
Manager
from
dan.mlflow
import
start_mlflow_run
from
dan.mlflow
import
MLflowNotInstalled
,
start_mlflow_run
from
dan.models
import
FCN_Encoder
from
dan.schedulers
import
exponential_dropout_scheduler
from
dan.transforms
import
aug_config
try
:
import
mlflow
MLFLOW
=
True
logger
.
info
(
"
MLflow Logging available.
"
)
except
ImportError
:
MLFLOW
=
False
logger
=
logging
.
getLogger
(
__name__
)
@@ -272,13 +280,14 @@ def run():
config
=
get_config
()
config_artifact
=
serialize_config
(
config
)
labels_artifact
=
""
dataset_name
=
config
[
"
mlflow
"
][
"
dataset_name
"
]
# The only key of this dict is the name of the dataset
dataset_name
=
config_artifact
[
"
dataset_params
"
][
"
datasets
"
].
keys
()[
0
]
labels_path
=
(
Path
(
config_artifact
[
"
dataset_params
"
][
"
datasets
"
][
dataset_name
])
/
"
labels.json
"
)
if
config
[
"
mlflow
"
]:
if
MLFLOW
and
config
[
"
mlflow
"
]:
with
start_mlflow_run
(
config
[
"
mlflow
"
])
as
run
:
logger
.
info
(
f
"
Set tags to MLflow on
{
config
[
'
mlflow
'
][
'
run_name
'
]
}
"
)
mlflow
.
set_tags
({
"
Dataset
"
:
config
[
"
mlflow
"
][
"
dataset_name
"
]})
@@ -303,6 +312,11 @@ def run():
)
else
:
train_and_test
(
0
,
config
,
True
)
elif
config
[
"
mlflow
"
]:
logger
.
error
(
"
Cannot log to MLflow as the `mlflow` module was not found in your environment.
"
)
raise
MLflowNotInstalled
()
else
:
if
(
config
[
"
training_params
"
][
"
use_ddp
"
]
Loading