-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathgraph_over_time.py
executable file
·67 lines (57 loc) · 2.27 KB
/
graph_over_time.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python2
import calendar
import datetime
import json
import subprocess
import time
import dateutil.parser
runs = json.load(open("list.json", "r"))
watermark_runs = ["x265_1.6_ntt-short-1", "x264_ntt"]
watermark_data = {}
psnr = []
psnrhvs = []
ssim = []
fastssim = []
def unix_time(dt):
epoch = datetime.datetime.utcfromtimestamp(0)
delta = dt - epoch
return delta.total_seconds()
for run in runs:
is_watermark_run = run["run_id"] in watermark_runs
is_master_run = (u"master" in run["info"]) and (
u"ntt-short-1" in run["info"]["task"]
)
if is_watermark_run or is_master_run:
filename = "runs/" + run["run_id"] + "/" + run["info"]["task"] + "/total.out"
try:
distortion = subprocess.check_output(["./distortion.m", filename, "0.1"])
if is_master_run:
date_str = subprocess.check_output(
[
"git",
"--git-dir=daala/.git",
"--work-tree=daala/",
"show",
"-s",
"--format=%ci",
run["info"]["commit"],
]
)
date_obj = dateutil.parser.parse(date_str).replace(tzinfo=None)
date_js = unix_time(date_obj) * 1000
psnr.append([date_js, distortion.split("\n")[0]])
psnrhvs.append([date_js, distortion.split("\n")[1]])
ssim.append([date_js, distortion.split("\n")[2]])
fastssim.append([date_js, distortion.split("\n")[3]])
if is_watermark_run:
watermark_run = run["info"]["codec"]
watermark_data[watermark_run] = {}
watermark_data[watermark_run]["psnr"] = distortion.split("\n")[0]
watermark_data[watermark_run]["psnrhvs"] = distortion.split("\n")[1]
watermark_data[watermark_run]["ssim"] = distortion.split("\n")[2]
watermark_data[watermark_run]["fastssim"] = distortion.split("\n")[3]
except subprocess.CalledProcessError:
continue
output = [psnr, psnrhvs, ssim, fastssim]
json.dump(output, open("time_series.json", "w"))
json.dump(watermark_data, open("watermark.json", "w"))