Skip to content

Instantly share code, notes, and snippets.

@MarvinTeichmann
Created May 11, 2017 09:58
Show Gist options
  • Save MarvinTeichmann/e426bb74b4fd79259bd1a037de7b51e6 to your computer and use it in GitHub Desktop.
Save MarvinTeichmann/e426bb74b4fd79259bd1a037de7b51e6 to your computer and use it in GitHub Desktop.
"""
Plots MaxF1 score.
-------------------------------------------------
The MIT License (MIT)
Copyright (c) 2017 Marvin Teichmann
More details: https://github.com/MarvinTeichmann/KittiSeg/blob/master/LICENSE
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import re
import numpy as np
import sys
import matplotlib.pyplot as plt
runfolder = '/home/mifs/mttt2/local_disk/RUNS/'
currun = 'paper/segmentation/xentropy_kitti_fcn_2016_10_15_01.18'
anafile = 'output.log'
output_folder = '/home/mifs/mttt2/github/multinet_paper/cvpr/images/results'
name = 'segmentation'
outname = os.path.join(output_folder, name)
filename = os.path.join(runfolder, currun, anafile)
eval_iters = 100
max_iters = 16000
def read_values(prop, typ):
regex_string = "%s\s+\(%s\)\s+:\s+(\d+\.\d+)" % (prop, typ)
regex = re.compile(regex_string)
value_list = [regex.search(line).group(1) for line in open(filename)
if regex.search(line) is not None]
float_list = [float(value) for value in value_list]
return float_list
label_list = xrange(eval_iters, max_iters+1, 100)
plt.figure(figsize=(8, 5))
plt.rcParams.update({'font.size': 14})
plt.plot(label_list, read_values('MaxF1', 'raw'),
label='MaxF1 (Raw)', marker=".", color='blue', linestyle=' ')
plt.plot(label_list, read_values('MaxF1', 'smooth'),
label='MaxF1 (Smoothed)', color='blue')
plt.plot(label_list, read_values('Average Precision', 'raw'),
label='Average Precision (Raw)', color='red', marker=".",
linestyle=' ')
plt.plot(label_list, read_values('Average Precision', 'smooth'),
label='Average Precision (Smoothed)', color='red')
plt.xlabel('Iteration')
plt.ylabel('Validation Score [%]')
plt.legend(loc=0)
plt.savefig(outname + ".pdf")
plt.savefig(outname + ".pgf")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment