This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torchvision.transforms.functional as TF | |
class RandomGammaCorrection(object): | |
""" | |
Apply Gamma Correction to the images | |
""" | |
def __init__(self, gamma = None): | |
self.gamma = gamma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/Abe404/segmentation_of_roots_in_soil_with_unet/blob/master/src/metrics.py | |
def get_metrics(y_pred, y_true, loss=float('nan')): | |
true_positives = np.sum(np.logical_and(y_pred == 1, y_true == 1)) | |
true_negatives = np.sum(np.logical_and(y_pred == 0, y_true == 0)) | |
false_positives = np.sum(np.logical_and(y_pred == 1, y_true == 0)) | |
false_negatives = np.sum(np.logical_and(y_pred == 0, y_true == 1)) | |
accuracy = (true_positives + true_negatives) / len(y_true) | |
assert not np.isnan(true_negatives) | |
assert not np.isnan(false_positives) |