add configurable ignore classes for KIEMetric
parent
4196e5d3d9
commit
6b173e630d
|
@ -54,6 +54,8 @@ PostProcess:
|
||||||
Metric:
|
Metric:
|
||||||
name: KIEMetric
|
name: KIEMetric
|
||||||
main_indicator: hmean
|
main_indicator: hmean
|
||||||
|
# Classes that will be ignored while computing F1 score.
|
||||||
|
ignore_classes: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25]
|
||||||
|
|
||||||
Train:
|
Train:
|
||||||
dataset:
|
dataset:
|
||||||
|
|
|
@ -24,8 +24,12 @@ __all__ = ['KIEMetric']
|
||||||
|
|
||||||
|
|
||||||
class KIEMetric(object):
|
class KIEMetric(object):
|
||||||
def __init__(self, main_indicator='hmean', **kwargs):
|
def __init__(self,
|
||||||
|
main_indicator='hmean',
|
||||||
|
ignore_classes=[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25],
|
||||||
|
**kwargs):
|
||||||
self.main_indicator = main_indicator
|
self.main_indicator = main_indicator
|
||||||
|
self.ignore_classes = ignore_classes
|
||||||
self.reset()
|
self.reset()
|
||||||
self.node = []
|
self.node = []
|
||||||
self.gt = []
|
self.gt = []
|
||||||
|
@ -40,7 +44,7 @@ class KIEMetric(object):
|
||||||
# self.results.append(result)
|
# self.results.append(result)
|
||||||
|
|
||||||
def compute_f1_score(self, preds, gts):
|
def compute_f1_score(self, preds, gts):
|
||||||
ignores = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25]
|
ignores = self.ignore_classes
|
||||||
C = preds.shape[1]
|
C = preds.shape[1]
|
||||||
classes = np.array(sorted(set(range(C)) - set(ignores)))
|
classes = np.array(sorted(set(range(C)) - set(ignores)))
|
||||||
hist = np.bincount(
|
hist = np.bincount(
|
||||||
|
|
Loading…
Reference in New Issue