trackeval/metrics/_base_metric.py
def summary_results(self, table_res):
"""Returns a simple summary of final results for a tracker"""
res = {}
for k in table_res.keys():
res[k] = dict(zip(self.summary_fields, self._summary_row(table_res[k])))
return res
trackeval/utils.py
from pandas import DataFrame
def write_summary_results(summaries, cls, output_folder):
"""Write summary results to file"""
out_file = os.path.join(output_folder, cls + '_summary.csv')
if os.path.exists(out_file):
os.remove(out_file)
os.makedirs(os.path.dirname(out_file), exist_ok=True)
for sums in summaries:
x = DataFrame(sums)
x = DataFrame(x.values.T, index=x.columns, columns=x.index)
with open(out_file, 'a', newline='') as f:
x.to_csv(f, mode="a", index=True)
f.write("\n")
def write_detailed_results(details, cls, output_folder):
"""Write detailed results to file"""
out_file = os.path.join(output_folder, cls + '_detailed.csv')
if os.path.exists(out_file):
os.remove(out_file)
os.makedirs(os.path.dirname(out_file), exist_ok=True)
for detail in details:
x = DataFrame(detail)
x = DataFrame(x.values.T, index=x.columns, columns=x.index)
col_classes = {"ori": []}
for col in x.columns.tolist():
if "_" in col:
theclass = col.split("", 1)[0]
if the_class not in col_classes.keys():
col_classes[the_class] = [col]
else:
col_classes[the_class].append(col)
else:
col_classes["ori"].append(col)
for v in col_classes.values():
tmp_df = x[v]
with open(out_file, 'a', newline='') as f:
tmp_df.to_csv(f, mode="a", index=True)
f.write("\n")
trackeval/metrics/_base_metric.py def summary_results(self, table_res): """Returns a simple summary of final results for a tracker""" res = {} for k in table_res.keys(): res[k] = dict(zip(self.summary_fields, self._summary_row(table_res[k]))) return res
trackeval/utils.py from pandas import DataFrame def write_summary_results(summaries, cls, output_folder): """Write summary results to file""" out_file = os.path.join(output_folder, cls + '_summary.csv') if os.path.exists(out_file): os.remove(out_file) os.makedirs(os.path.dirname(out_file), exist_ok=True) for sums in summaries: x = DataFrame(sums) x = DataFrame(x.values.T, index=x.columns, columns=x.index) with open(out_file, 'a', newline='') as f: x.to_csv(f, mode="a", index=True) f.write("\n")
def write_detailed_results(details, cls, output_folder): """Write detailed results to file""" out_file = os.path.join(output_folder, cls + '_detailed.csv') if os.path.exists(out_file): os.remove(out_file) os.makedirs(os.path.dirname(out_file), exist_ok=True) for detail in details: x = DataFrame(detail) x = DataFrame(x.values.T, index=x.columns, columns=x.index) col_classes = {"ori": []} for col in x.columns.tolist(): if "_" in col: theclass = col.split("", 1)[0] if the_class not in col_classes.keys(): col_classes[the_class] = [col] else: col_classes[the_class].append(col) else: col_classes["ori"].append(col) for v in col_classes.values(): tmp_df = x[v] with open(out_file, 'a', newline='') as f: tmp_df.to_csv(f, mode="a", index=True) f.write("\n")