delete blank lines and modify forward_train

This commit is contained in:
Topdu
2021-08-19 09:31:02 +00:00
parent a11e219970
commit 55b76dcaa5
7 changed files with 388 additions and 288 deletions
+3 -8
View File
@@ -189,9 +189,9 @@ def train(config,
use_nrtr = config['Architecture']['algorithm'] == "NRTR"
try:
try:
model_type = config['Architecture']['model_type']
except:
except:
model_type = None
if 'start_epoch' in best_model_dict:
@@ -216,11 +216,8 @@ def train(config,
images = batch[0]
if use_srn:
model_average = True
if use_srn or model_type == 'table':
if use_srn or model_type == 'table' or use_nrtr:
preds = model(images, data=batch[1:])
elif use_nrtr:
max_len = batch[2].max()
preds = model(images, batch[1][:,:2+max_len])
else:
preds = model(images)
loss = loss_class(preds, batch)
@@ -405,9 +402,7 @@ def preprocess(is_train=False):
alg = config['Architecture']['algorithm']
assert alg in [
'EAST', 'DB', 'SAST', 'Rosetta', 'CRNN', 'STARNet', 'RARE', 'SRN',
'CLS', 'PGNet', 'Distillation', 'NRTR', 'TableAttn'
]
device = 'gpu:{}'.format(dist.ParallelEnv().dev_id) if use_gpu else 'cpu'