add for SEED

This commit is contained in:
tink2123
2021-07-22 19:58:14 +08:00
parent 38801c7f5e
commit 59cc4efdc5
21 changed files with 1868 additions and 54 deletions
+10 -5
View File
@@ -187,6 +187,7 @@ def train(config,
use_srn = config['Architecture']['algorithm'] == "SRN"
model_type = config['Architecture']['model_type']
algorithm = config['Architecture']['algorithm']
if 'start_epoch' in best_model_dict:
start_epoch = best_model_dict['start_epoch']
@@ -210,10 +211,14 @@ def train(config,
images = batch[0]
if use_srn:
model_average = True
if use_srn or model_type == 'table':
preds = model(images, data=batch[1:])
else:
preds = model(images)
# if use_srn or model_type == 'table' or algorithm == "ASTER":
# preds = model(images, data=batch[1:])
# else:
# preds = model(images)
preds = model(images, data=batch[1:])
state_dict = model.state_dict()
# for key in state_dict:
# print(key)
loss = loss_class(preds, batch)
avg_loss = loss['loss']
avg_loss.backward()
@@ -395,7 +400,7 @@ def preprocess(is_train=False):
alg = config['Architecture']['algorithm']
assert alg in [
'EAST', 'DB', 'SAST', 'Rosetta', 'CRNN', 'STARNet', 'RARE', 'SRN',
'CLS', 'PGNet', 'Distillation', 'TableAttn'
'CLS', 'PGNet', 'Distillation', 'TableAttn', 'ASTER'
]
device = 'gpu:{}'.format(dist.ParallelEnv().dev_id) if use_gpu else 'cpu'