text stringlengths 0 828 |
|---|
return compile(compiled_regex)" |
551,"def as_command(self): |
""""""Creates the click command wrapping the function |
"""""" |
try: |
params = self.unbound_func.__click_params__ |
params.reverse() |
del self.unbound_func.__click_params__ |
except AttributeError: |
params = [] |
help = inspect.getdoc(self.real_func) |
if isinstance(help, bytes): |
help = help.decode('utf-8') |
self.options.setdefault('help', help) |
@pass_script_info_decorator |
def callback(info, *args, **kwargs): |
if self.with_reloader: |
app = info.load_app() |
if app.debug: |
def inner(): |
return self.command_callback(info, *args, **kwargs) |
run_with_reloader(inner, extra_files=get_reloader_extra_files()) |
return |
self.command_callback(info, *args, **kwargs) |
return self.cls(name=self.name, callback=callback, params=params, **self.options)" |
552,"def command_line_options(command_line_arguments): |
""""""Parse the program options"""""" |
# set up command line parser |
parser = argparse.ArgumentParser(description=__doc__, |
formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
parser.add_argument('-d', '--files', required=True, nargs='+', help = ""A list of score files to evaluate."") |
parser.add_argument('-b', '--baselines', default=[], nargs='+', help = ""A list of baseline results to add to the plot"") |
parser.add_argument('-D', '--directory', default = '.', help = ""A directory, where to find the --files"") |
parser.add_argument('-B', '--baseline-directory', default = '.', help = ""A directory, where to find the --baselines"") |
parser.add_argument('-R', '--auto-baselines', choices = ('bioid', 'mit-cmu'), help = ""Automatically add the baselines for the given database"") |
parser.add_argument('-l', '--legends', nargs='+', help = ""A list of legend strings used for ROC, CMC and DET plots; if given, must be the same number than --files plus --baselines."") |
parser.add_argument('-w', '--output', default = 'FROC.pdf', help = ""If given, FROC curves will be plotted into the given pdf file."") |
parser.add_argument('-c', '--count-detections', action='store_true', help = ""Counts the number of detections (positive is higher than negative, per file)."") |
parser.add_argument('-n', '--max', type=int, nargs=2, default=(160,70), help = ""The highest false alarms and the lowest detection rate to plot"") |
parser.add_argument('-t', '--title', default='FROC', help = ""The title of the plot"") |
parser.add_argument('--self-test', action='store_true', help=argparse.SUPPRESS) |
# add verbosity option |
bob.core.log.add_command_line_option(parser) |
args = parser.parse_args(command_line_arguments) |
bob.core.log.set_verbosity_level(logger, args.verbose) |
if args.legends is not None: |
count = len(args.files) + (len(args.baselines) if args.baselines is not None else 0) |
if len(args.legends) != count: |
logger.error(""The number of --files (%d) plus --baselines (%d) must be the same as --legends (%d)"", len(args.files), len(args.baselines) if args.baselines else 0, len(args.legends)) |
args.legends = None |
# update legends when they are not specified on command line |
if args.legends is None: |
args.legends = args.files if not args.baselines else args.files + args.baselines |
args.legends = [l.replace(""_"",""-"") for l in args.legends] |
if args.auto_baselines == 'bioid': |
args.baselines.extend([""baselines/baseline_detection_froba_mct_BIOID"", ""cosmin/BIOID/face.elbp.proj0.var.levels10.roc""]) |
args.legends.extend([""Froba"", ""Cosmin""]) |
elif args.auto_baselines == 'mit-cmu': |
args.baselines.extend([""baselines/baseline_detection_fcboost_MIT+CMU"", ""baselines/baseline_detection_viola_rapid1_MIT+CMU"", ""cosmin/MIT+CMU/face.elbp.proj0.var.levels10.roc""]) |
args.legends.extend([""FcBoost"", ""Viola"", ""Cosmin""]) |
return args" |
553,"def main(command_line_arguments=None): |
""""""Reads score files, computes error measures and plots curves."""""" |
args = command_line_options(command_line_arguments) |
# get some colors for plotting |
cmap = mpl.cm.get_cmap(name='hsv') |
count = len(args.files) + (len(args.baselines) if args.baselines else 0) |
colors = [cmap(i) for i in numpy.linspace(0, 1.0, count+1)] |
# First, read the score files |
logger.info(""Loading %d score files"" % len(args.files)) |
scores = [read_score_file(os.path.join(args.directory, f)) for f in args.files] |
false_alarms = [] |
detection_rate = [] |
logger.info(""Computing FROC curves"") |
for score in scores: |
# compute some thresholds |
tmin = min(score[2]) |
tmax = max(score[2]) |
count = 100 |
thresholds = [tmin + float(x)/count * (tmax - tmin) for x in range(count+2)] |
false_alarms.append([]) |
detection_rate.append([]) |
for threshold in thresholds: |
detection_rate[-1].append(numpy.count_nonzero(numpy.array(score[1]) >= threshold) / float(score[0])) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.