Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 numpy as np | |
import keras.backend as K | |
import tensorflow as tf | |
def metrics_np(y_true, y_pred, metric_name, metric_type='standard', drop_last = True, mean_per_class=False, verbose=False): | |
""" | |
Compute mean metrics of two segmentation masks, via numpy. | |
IoU(A,B) = |A & B| / (| A U B|) | |
Dice(A,B) = 2*|A & B| / (|A| + |B|) |
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
# from US census website (cb_2017_us_state_20m.shp, no hard-links because they keep changing them...) | |
us_states = ['Alaska', 'California', 'Colorado', 'District of Columbia', 'Idaho', 'Illinois', 'Iowa', 'Kentucky', 'Louisiana', 'Maryland', 'Minnesota', 'Missouri', 'New York', 'Oregon', 'Tennessee', 'Texas', 'Virginia', 'Wisconsin', 'Alabama', 'Arizona', 'Arkansas', 'Indiana', 'Kansas', 'Maine', 'Connecticut', 'Delaware', 'Georgia', 'Hawaii', 'South Carolina', 'South Dakota', 'Massachusetts', 'Michigan', 'Mississippi', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'North Carolina', 'North Dakota', 'Rhode Island', 'Ohio', 'Oklahoma', 'Pennsylvania', 'Florida', 'Montana', 'Utah', 'Vermont', 'Washington', 'West Virginia', 'Wyoming', 'Puerto Rico'] |