From e9232a4b67cf49b126cda9865982e57f81330d02 Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Thu, 24 Jan 2013 14:45:11 +0400 Subject: [PATCH] add parameter to control range and extended range for annotations --- apps/sft/misc/roc_test.py | 14 ++++++++++++++ apps/sft/misc/sft.py | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/sft/misc/roc_test.py b/apps/sft/misc/roc_test.py index bc436af9b..5cfcfb8ed 100755 --- a/apps/sft/misc/roc_test.py +++ b/apps/sft/misc/roc_test.py @@ -14,6 +14,13 @@ bgr = { "red" : ( 0, 0, 255), "green" : ( 0, 255, 0), "blue" : (255, 0 , 0)} +def range(s): + try: + lb, rb = map(int, s.split(',')) + return lb, rb + except: + raise argparse.ArgumentTypeError("Must be lb, rb") + def call_parser(f, a): return eval( "sft.parse_" + f + "('" + a + "')") @@ -31,11 +38,16 @@ if __name__ == "__main__": parser.add_argument("-o", "--output", dest = "output", type = str, metavar= "path", help = "Path to store resultiong image.", default = "./roc.png") parser.add_argument("-n", "--nscales", dest = "nscales", type = int, metavar= "n", help = "Prefered count of scales from min to max.", default = 55) + parser.add_argument("-r", "--scale-range", dest = "scale_range", type = range, default = (128 * 0.4, 128 * 2.4)) + parser.add_argument("-e", "--extended-range-ratio", dest = "ext_ratio", type = float, default = 1.25) + # required parser.add_argument("-f", "--anttn-format", dest = "anttn_format", choices = ['inria', 'caltech', "idl"], help = "Annotation file for test sequence.", required = True) args = parser.parse_args() + print args.scale_range + print args.cascade # # parse annotations sft.initPlot() @@ -64,6 +76,8 @@ if __name__ == "__main__": boxes = samples[tail] boxes = sft.norm_acpect_ratio(boxes, 0.5) + boxes = [b for b in boxes if (b[3] - b[1]) > args.scale_range[0] / args.ext_ratio] + boxes = [b for b in boxes if (b[3] - b[1]) < args.scale_range[1] * args.ext_ratio] nannotated = nannotated + len(boxes) nframes = nframes + 1 diff --git a/apps/sft/misc/sft.py b/apps/sft/misc/sft.py index a732c77db..87004b4ca 100644 --- a/apps/sft/misc/sft.py +++ b/apps/sft/misc/sft.py @@ -75,19 +75,22 @@ def initPlot(name = "ROC curve Bahnhof"): """Show resulted plot""" def showPlot(file_name): - # plt.savefig(file_name) + plt.savefig(file_name) plt.axis((pow(10, -3), pow(10, 1), 0.0, 1)) plt.yticks( [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.64, 0.8, 1], ['.05', '.10', '.20', '.30', '.40', '.50', '.64', '.80', '1'] ) plt.show() def match(gts, dts): - # Cartesian product for each detection BB_dt with each BB_gt - overlaps = [[dt.overlap(gt) for gt in gts]for dt in dts] - matches_gt = [0]*len(gts) matches_dt = [0]*len(dts) matches_ignore = [0]*len(dts) + if len(gts) == 0: + return matches_dt, matches_ignore + + # Cartesian product for each detection BB_dt with each BB_gt + overlaps = [[dt.overlap(gt) for gt in gts]for dt in dts] + for idx, row in enumerate(overlaps): imax = row.index(max(row))