def segmentation(num_classes, ignore_idx=255, attach_to=None): confusion_matrix = metrics.ConfusionMatrix(num_classes=num_classes, ignore_idx=ignore_idx, attach_to=attach_to) return metrics.MetricCompose( metric_dict={ 'acc': metrics.Accuracy(attach_to=attach_to), 'confusion_matrix': confusion_matrix, 'miou': metrics.mIoU(confusion_matrix) })
def monocular_depth(attach_to=None): return metrics.MetricCompose( metric_dict={ 'rmse': metrics.RootMeanSquaredError(attach_to=attach_to), 'rmse_log': metrics.RootMeanSquaredError(log_scale=True, attach_to=attach_to), 'rmse_scale_inv': metrics.ScaleInveriantMeanSquaredError(attach_to=attach_to), 'abs rel': metrics.AbsoluteRelativeDifference(attach_to=attach_to), 'sq rel': metrics.SquaredRelativeDifference(attach_to=attach_to), 'percents within thresholds': metrics.Threshold(thresholds=[1.25, 1.25**2, 1.25**3], attach_to=attach_to) })
def loss_metric(loss_fn): return metrics.MetricCompose( metric_dict={'loss': metrics.AverageMetric(loss_fn)})
def regression(attach_to=None): return metrics.MetricCompose( metric_dict={'mse': metrics.MeanSquaredError(attach_to=attach_to)})
def classification(attach_to=None): return metrics.MetricCompose( metric_dict={'acc': metrics.Accuracy(attach_to=attach_to)})