File size: 6,625 Bytes
abd2a81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
import argparse
import os
import matplotlib.pyplot as plt
import numpy as np
from lydorn_utils import python_utils
from lydorn_utils import print_utils
def get_args():
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument(
'--dirpath',
default="/home/lydorn/data/mapping_challenge_dataset/eval_runs",
type=str,
help='Path to eval directory')
args = argparser.parse_args()
return args
def plot_metric(dirpath, info_list):
legend = []
for info in info_list:
metrics_filepath = os.path.join(dirpath, info["metrics_filepath"])
metrics = python_utils.load_json(metrics_filepath)
if metrics:
max_angle_diffs = np.array(metrics["max_angle_diffs"])
total = len(max_angle_diffs)
angle_thresholds = range(0, 91)
fraction_under_threshold_list = []
for angle_threshold in angle_thresholds:
fraction_under_threshold = np.sum(max_angle_diffs < angle_threshold) / total
fraction_under_threshold_list.append(fraction_under_threshold)
# Plot
plt.plot(angle_thresholds, fraction_under_threshold_list)
# Compute mean
mean_error = np.mean(max_angle_diffs)
legend.append(f"{info['name']}: {mean_error:.1f}°")
else:
print_utils.print_warning("WARNING: could not open {}".format(info["metrics_filepath"]))
plt.legend(legend, loc='lower right')
plt.xlabel("Threshold (degrees)")
plt.ylabel("Fraction of detections")
axes = plt.gca()
axes.set_xlim([0, 90])
axes.set_ylim([0, 1])
title = f"Cumulative max tangent angle error per detection"
plt.title(title)
plt.savefig(title.lower().replace(" ", "_") + ".pdf")
plt.show()
def main():
args = get_args()
# Mapping challenge:
info_list = [
{
"name": "UResNet101 (no field), simple poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.field_off.train_val | 2020-05-21 08:33:20/test.metrics.test.annotation.poly.simple.tol_0.125.json"
},
{
"name": "UResNet101 (with field), simple poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.train_val | 2020-05-21 08:32:48/test.metrics.test.annotation.poly.simple.tol_0.125.json"
},
{
"name": "UResNet101 (with field), our poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.train_val | 2020-05-21 08:32:48/test.metrics.test.annotation.poly.acm.tol_0.125.json"
},
{
"name": "UResNet101 (no $L_{align90}$), our poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.align90_off.train_val | 2020-11-02 07:34:43/test.metrics.test.annotation.poly.acm.tol_0.125.json"
},
{
"name": "UResNet101 (no $L_{int edge}$), our poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.edge_int_off.train_val | 2020-11-02 07:34:54/test.metrics.test.annotation.poly.acm.tol_0.125.json"
},
{
"name": "UResNet101 (no $L_{int align}$ and $L_{edge align}$), our poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.seg_framefield_off.train_val | 2020-10-29 11:27:52/test.metrics.test.annotation.poly.acm.tol_0.125.json"
},
{
"name": "UResNet101 (no $L_{smooth}$), our poly.",
"metrics_filepath": "mapping_dataset.unet_resnet101_pretrained.smooth_off.train_val | 2020-10-29 11:18:33/test.metrics.test.annotation.poly.acm.tol_0.125.json"
},
{
"name": "PolyMapper",
"metrics_filepath": "mapping_dataset.polymapper | 0000-00-00 00:00:00/test.metrics.test.annotation.poly.json"
},
{
"name": "U-Net variant, ASIP poly.",
"metrics_filepath": "mapping_dataset.asip | 0000-00-00 00:00:00/test.metrics.test.annotation.poly.json"
},
{
"name": "Zorzi et al.",
"metrics_filepath": "mapping_dataset.zorzi | 0000-00-00 00:00:00/test.metrics.test.annotation.poly.json"
},
{
"name": "U-Net variant, UResNet101 poly",
"metrics_filepath": "mapping_dataset.open_solution_full | 0000-00-00 00:00:00/test.metrics.test.annotation.seg_cleaned.poly.json"
}
]
# Inria Polygonized Dataset
# info_list = [
# {
# "name": "UResNet101 (no field), simple poly.",
# "metrics_filepath": "/home/lydorn/data/AerialImageDataset/raw/test/pred_ours_leaderboard_new_losses.field_off/poly_shapefile.simple.tol_1/aggr_metrics.json"
# },
# {
# "name": "UResNet101 (with field), our poly.",
# "metrics_filepath": "/home/lydorn/data/AerialImageDataset/raw/test/pred_ours_leaderboard/poly_shapefile.acm.tol_0.125/aggr_metrics.json"
# },
# {
# "name": "Zorzi et al.",
# "metrics_filepath": "/home/lydorn/data/AerialImageDataset/raw/test/pred_zorzi/shapes/aggr_metrics.json"
# },
# {
# "name": "ICTNet, simple poly.",
# "metrics_filepath": "/home/lydorn/data/AerialImageDataset/raw/test/pred_ictnet/shp/aggr_metrics.json"
# },
# {
# "name": "Khvedchenya, simple poly.",
# "metrics_filepath": "/home/lydorn/data/AerialImageDataset/raw/test/pred_khvedchenya/shp/aggr_metrics.json"
# },
# ]
# LuxCarta's Bangkok image
# info_list = [
# {
# "name": "ACM",
# "metrics_filepath": "/home/lydorn/repos/lydorn/frame_field_learning/frame_field_learning/test_images/Bangkok/Bangkok3bands.poly_acm.metrics.json"
# },
# {
# "name": "ASM",
# "metrics_filepath": "/home/lydorn/repos/lydorn/frame_field_learning/frame_field_learning/test_images/Bangkok/Bangkok3bands.poly_asm.metrics.json"
# },
# {
# "name": "ASM regularized",
# "metrics_filepath": "/home/lydorn/repos/lydorn/frame_field_learning/frame_field_learning/test_images/Bangkok/Bangkok3bands.reg.metrics.json"
# },
# {
# "name": "Company",
# "metrics_filepath": "/home/lydorn/repos/lydorn/frame_field_learning/frame_field_learning/test_images/Bangkok/Luxcarta/Building_Thailand_Bangkok_pansharpened25.metrics.json"
# },
# ]
plot_metric(args.dirpath, info_list)
if __name__ == '__main__':
main()
|