Skip to content

Add performance recording and plot during training #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A toolbox of OCR models, algorithms, and pipelines based on MindSpore

**Features:**

- Unified framework to support training text detection and recogintion models
- Support training and evaluation for text detection and recogintion models


## Quick Start (for dev)
Expand Down
6 changes: 3 additions & 3 deletions configs/det/db_r50_icdar15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ scheduler:
scheduler: "cosine_decay"
min_lr: 0.00001
lr: 0.007
num_epochs: 100
warmup_epochs: 3
decay_epochs: 97
num_epochs: 5
warmup_epochs: 2
decay_epochs: 3

optimizer:
opt: "momentum"
Expand Down
2 changes: 1 addition & 1 deletion configs/rec/crnn_icdar15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ eval:
num_keys_to_net: 1 # num inputs for network forward func

loader:
shuffle: True # TODO: tbc
shuffle: False
batch_size: 64
drop_remainder: False
max_rowsize: 12
Expand Down
12 changes: 0 additions & 12 deletions mindocr/data/transforms/modelzoo_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
__all__ = ['MZRandomColorAdjust', 'MZScalePad', 'MZResizeByGrid', 'MZRandomCropData',
'MZRandomScaleByShortSide', 'MZMakeSegDetectionData', 'MZMakeBorderMap', 'MZIncorrectNormToCHW']

# TODO: the input pixel value is in range [0, 255] or [0, 1]?
# TODO: Does it support BGR mode?
class MZRandomColorAdjust():
def __init__(self, brightness=32.0 / 255, saturation=0.5, to_numpy=False):
Expand Down Expand Up @@ -134,18 +133,7 @@ def __call__(self, data):
if polys is None:
return data

# TODO: compute in np array, not list
'''
#if self.is_train:
# new_polys = []
for poly in polys:
poly[:, 0] = poly[:, 0] * w_scale
poly[:, 1] = poly[:, 1] * h_scale
new_polys.append(poly)
polys = new_polys
polys[:, :, 0] = polys[:, :, 0] * w_scale
polys[:, :, 1] = polys[:, :, 1] * h_scale
'''
polys[:, :, 0] = polys[:, :, 0] * w_scale
polys[:, :, 1] = polys[:, :, 1] * h_scale

Expand Down
217 changes: 0 additions & 217 deletions mindocr/metrics/_iou_compute.py

This file was deleted.

21 changes: 1 addition & 20 deletions mindocr/metrics/det_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
TODO: overwrite

'''

from typing import List

import numpy as np
from mindspore import nn
from shapely.geometry import Polygon
from .meters import AverageMeter

__all__ = ['DetMetric']



def _get_intersect(pD, pG):
return pD.intersection(pG).area

Expand All @@ -22,24 +21,6 @@ def _get_iou(pD, pG):
return pD.intersection(pG).area / pD.union(pG).area


class AverageMeter:
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()

def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0

def update(self, val, n=1):
self.val = val
self.sum += val * n
self.count += n
self.avg = self.sum / self.count


class DetectionIoUEvaluator:
def __init__(self, min_iou=0.5, min_intersect=0.5):
self._min_iou = min_iou
Expand Down
23 changes: 23 additions & 0 deletions mindocr/metrics/meters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'''
Contain meter classes for recording and aggregating measured values
'''

class AverageMeter:
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()

def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0

def update(self, val, n=1):
self.val = val
self.sum += val * n
self.count += n
self.avg = self.sum / self.count

def get(self):
return self.avg
2 changes: 1 addition & 1 deletion mindocr/metrics/rec_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self,
ignore_space=True,
filter_ood=True,
lower=True,
print_flag=True,
print_flag=False,
**kwargs):
super().__init__()
self.clear()
Expand Down
Loading