Skip to content
Snippets Groups Projects
Commit 5d53985c authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Fixed some issues with the rst print

parent 98a1c73d
No related branches found
No related tags found
1 merge request!35Implemented IJBA customized plot
Pipeline #
......@@ -2,46 +2,49 @@
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
from __future__ import print_function
"""
This script parses through the given directory, collects all results of
experiments using bob.db.ijba and dumps a nice copy/paste rst text.
experiments using bob.db.ijba and dumps a nice copy/paste ReStructuredText (RST).
It supports comparison (--report-type comparison) and search (--report-type search) experiments
For comparison, we have a RST table like this:
For comparison, the following command dumps:
./bin/bob_ijba_collect_results.py <comparison-path> -r comparison
+-----------------+-----------------+-----------------+-----------------+--------------------------+
| CMC% (R=1) | TPIR% (FAR=0.1) | TPIR% (FAR=0.01)|TPIR% (FAR=0.001)| split |
| RR | TPIR% (FAR=0.1) | TPIR% (FAR=0.01)|TPIR% (FAR=0.001)| split |
+=================+=================+=================+=================+==========================+
| 00000 |0000000 |00000000 |00000 |split 0 |
+-----------------+-----------------+-----------------+-----------------+--------------------------+
| |
For search, the following command dumps:
For search, we have a RST table like this:
./bin/bob_ijba_collect_results.py <search-path> -r search
+-----------------+-----------------+-----------------+--------------------------+
| DIR% (FAR=0.1) | DIR% (FAR=0.01) | DIR% (FAR=0.001)| split |
+=================+=================+=================+==========================+
| 00000 |000000 |0000000 |00000000 |
+-------------------------+-------------------------+--------------------------+
| DIR% (rank=1, FAR=0.1) | DIR% (rank=1, FAR=0.01) | split |
+=========================+=========================+==========================+
| 00000 |000000 |00000000 |
"""
from __future__ import print_function
import sys, os, glob
import argparse
import numpy
import bob.measure
import bob.core
logger = bob.core.log.setup("bob.bio.base")
from argparse import RawTextHelpFormatter
from bob.bio.base.script.collect_results import Result, recurse, add_results
far_thresholds = [0.1, 0.01, 0.001]
logger = bob.core.log.setup("bob.bio.base")
def command_line_arguments(command_line_parameters):
......@@ -49,13 +52,10 @@ def command_line_arguments(command_line_parameters):
# set up command line parser
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-D', '--directory', default=".", help = "The directory where the results should be collected from; might include search patterns as '*'.")
parser.add_argument('-o', '--output', help = "Name of the output file that will contain the EER/HTER scores")
parser.add_argument('-r', '--report-type', default="comparison", choices=("comparison", "search"), help = "Type of the report. For `comparison`, CMC(rank=1) and TPIR (FAR=[0.1, 0.01 and 0.001] ) will be reported. For the search DIR (rank=1) and TPIR (FAR=[0.1, 0.01 and 0.001] is reported")
formatter_class=RawTextHelpFormatter)
parser.add_argument('--self-test', action='store_true', help=argparse.SUPPRESS)
parser.add_argument('directory', default=".", help = "The directory where the results should be collected from.")
parser.add_argument('-r', '--report-type', default="comparison", choices=("comparison", "search"), help = "Type of the report. For `comparison`, RR and TPIR (FAR=[0.1, 0.01 and 0.001] ) will be reported. For the search DIR (rank=1, under FAR=[0.1, 0.01]) is reported")
bob.core.log.add_command_line_option(parser)
......@@ -93,7 +93,7 @@ def compute_comparison(args, directories):
def plot_comparison_table(cmc_r1, fnmr):
grid = "+-----------------+-----------------+-----------------+-----------------+--------------------------+\n"
grid += "| CMC% (R=1) | TPIR% (FAR=0.1) | TPIR% (FAR=0.01)|TPIR% (FAR=0.001)| split |\n"
grid += "| RR | TPIR% (FAR=0.1) | TPIR% (FAR=0.01)|TPIR% (FAR=0.001)| split |\n"
grid += "+=================+=================+=================+=================+==========================+\n"
for cmc, fnmr_0, fnmr_1, fnmr_2, split in zip(cmc_r1, fnmr[0], fnmr[1], fnmr[2], range(len(cmc_r1))):
......@@ -147,33 +147,30 @@ def compute_search(args, directories):
"""
def plot_search_table(dira):
grid = "+-----------------+-----------------+-----------------+--------------------------+\n"
grid += "| DIR% (FAR=0.1) | DIR% (FAR=0.01) | DIR% (FAR=0.001)| split |\n"
grid += "+=================+=================+=================+==========================+\n"
grid = "+----------------------+----------------------+--------------------------+\n"
grid += "| DIR% (R=1, FAR=0.1) | DIR% (R=1, FAR=0.01) | split |\n"
grid += "+======================+======================+==========================+\n"
n_splits = len(dira[0])
for dira_0, dira_1, dira_2, split in zip(dira[0], dira[1], dira[2], range(n_splits)):
grid += "|{:17s}|{:17s}|{:17s}|{:26s}|\n".format(str(round(dira_0.nonorm_dev,5)*100),
str(round(dira_1.nonorm_dev,5)*100),
str(round(dira_2.nonorm_dev,5)*100),
"split {0}".format(split))
grid += "+-----------------+-----------------+-----------------+--------------------------+\n"
for dira_0, dira_1, split in zip(dira[0], dira[1], range(n_splits)):
grid += "|{:22s}|{:22s}|{:26s}|\n".format(str(round(dira_0.nonorm_dev,5)*100),
str(round(dira_1.nonorm_dev,5)*100),
"split {0}".format(split))
grid += "+----------------------+----------------------+--------------------------+\n"
dira_0 = compute_mean_std(dira[0])
dira_1 = compute_mean_std(dira[1])
dira_2 = compute_mean_std(dira[2])
grid += "|**{:6s}({:5s})**|**{:6s}({:5s})**|**{:6s}({:5s})**|{:26s}|\n".format(
str(round(dira_0[0],4)*100),str(round(dira_0[1],4)*100),
str(round(dira_1[0],4)*100),str(round(dira_1[1],4)*100),
str(round(dira_2[0],4)*100),str(round(dira_2[1],4)*100),
"mean(std)")
grid += "+-----------------+-----------------+-----------------+--------------------------+\n"
grid += "|**{:6s}({:6s})** |**{:6s}({:6s})** |{:26s}|\n".format(
str(round(dira_0[0],4)*100),str(round(dira_0[1],4)*100),
str(round(dira_1[0],4)*100),str(round(dira_1[1],4)*100),
"mean(std)")
grid += "+----------------------+----------------------+--------------------------+\n"
return grid
def compute_dir(args, directories):
dira = []
for f in far_thresholds:
for f in far_thresholds[0:2]:
args.criterion = "DIR"
args.far_threshold = f
dira.append(search_results(args, directories))
......@@ -184,7 +181,6 @@ def compute_search(args, directories):
args = args
args.rank = 1
args.criterion = "DIR"
dira = compute_dir(args, directories)
return plot_search_table(dira)
......@@ -194,7 +190,8 @@ def main(command_line_parameters = None):
args = command_line_arguments(command_line_parameters)
# collect results
directories = glob.glob(args.directory)
if not os.path.exists(args.directory):
raise ValueError("The directory `%s` does not exists"%args.directory)
# Injecting some variables
args.dev = "scores-dev"
......@@ -203,7 +200,7 @@ def main(command_line_parameters = None):
args.ztnorm = "ztnorm"
if args.report_type == "comparison":
print(compute_comparison(args, directories))
print(compute_comparison(args, [args.directory]))
else:
print(compute_search(args, directories))
print(compute_search(args, [args.directory]))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment