Open Ghost0405 opened 1 year ago
class EdgeAccuracy(nn.Module):
"""
Measures the accuracy of the edge map
"""
def __init__(self, threshold=0.5):
super(EdgeAccuracy, self).__init__()
self.threshold = threshold
def __call__(self, inputs, outputs):
labels = (inputs > self.threshold)
outputs = (outputs > self.threshold)
relevant = torch.sum(labels.float())
selected = torch.sum(outputs.float())
if relevant == 0 and selected == 0:
return torch.tensor(1), torch.tensor(1)
true_positive = ((outputs == labels) * labels).float()
recall = torch.sum(true_positive) / (relevant + 1e-8)
precision = torch.sum(true_positive) / (selected + 1e-8)
return precision, recall
according to this the relevant and selective must have a value greater than zero to get result. I thing the edge you have generated had values below threshold. make sure edges to have only values of 0 and 1
When I am training model = 1, these two values are always 1, is this correct?Which loss in the logs_edge.dat file should you pay more attention to when training model = 1?