MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / _fast_hist

Method _fast_hist

PATH/core/utils.py:830–845  ·  view source on GitHub ↗
(self, label_true, label_pred, n_class)

Source from the content-addressed store, hash-verified

828 return 2 / (1 / precision + 1 / recall), precision, recall
829
830 def _fast_hist(self, label_true, label_pred, n_class):
831 mask = (label_true >= 0) & (label_true < n_class)
832 mask &= (label_pred >= 0) & (label_pred < n_class)
833
834 if self.ignore_index is not None:
835 mask = mask & (label_true != self.ignore_index)
836
837 hist = np.bincount(
838 n_class * label_true[mask].astype(int) +
839 label_pred[mask], minlength=n_class**2)
840
841 # print(np.unique(label_true))
842 # print(np.unique(label_pred))
843 hist = hist.reshape(n_class, n_class)
844
845 return hist
846
847 def update(self, label_preds, label_trues):
848 self.reduced_confusion_matrix = None

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected