Skip to content

Commit

Permalink
fix ips print error
Browse files Browse the repository at this point in the history
  • Loading branch information
WenmuZhou committed Aug 29, 2023
1 parent 6bdef6a commit 8b780d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Train:
shuffle: true
batch_size_per_card: 128
drop_last: true
num_workers: 0
num_workers: 4
Eval:
dataset:
name: SimpleDataSet
Expand Down
8 changes: 3 additions & 5 deletions torchocr/engine/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ def train(self):
metric = self.eval_class.get_metric()
train_stats.update(metric)

self.lr_scheduler.step()

train_batch_time = time.time() - reader_start
train_batch_cost += train_batch_time
eta_meter.update(train_batch_time)
global_step += 1
total_samples += len(batch[0])

self.lr_scheduler.step()

# logger
stats = {
k: float(v) if v.shape == [] else v.detach().cpu().numpy().mean()
Expand All @@ -223,11 +223,10 @@ def train(self):
f'ips: {total_samples / train_batch_cost:.5f} samples/s, '
f'eta: {eta_sec_format}')
self.logger.info(strs)

total_samples = 0
train_reader_cost = 0.0
train_batch_cost = 0.0

reader_start = time.time()
if self.local_rank == 0:
save_ckpt(self.model, self.cfg, self.optimizer, self.lr_scheduler, epoch, global_step, best_metric,
is_best=False)
Expand All @@ -254,7 +253,6 @@ def train(self):
best_metric[self.eval_class.main_indicator], global_step)
best_str = f"best metric, {', '.join(['{}: {}'.format(k, v) for k, v in best_metric.items()])}"
self.logger.info(best_str)
reader_start = time.time()
best_str = f"best metric, {', '.join(['{}: {}'.format(k, v) for k, v in best_metric.items()])}"
self.logger.info(best_str)
if self.writer is not None:
Expand Down

0 comments on commit 8b780d8

Please sign in to comment.