Simon Bruder
ecd7808dd1
Older scripts (that now have no real purpose) or ones that require packages that are not in nixpkgs are not updated. They should either be removed or fixed at a later date.
52 lines
1.6 KiB
Python
Executable file
52 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ ps.pandas ps.numpy ps.tabulate ])"
|
|
import pandas as pd
|
|
import numpy as np
|
|
import sys
|
|
from pprint import pprint
|
|
from tabulate import tabulate
|
|
|
|
|
|
def process_raw_line(line):
|
|
fields = line.rstrip().split(" ")
|
|
fields = [field.split(":")[-1] for field in fields]
|
|
fields[5] = fields[5][1:-1]
|
|
fields[0] = int(fields[0])
|
|
fields[1:] = list(map(np.float, fields[1:]))
|
|
return fields
|
|
|
|
|
|
with open(sys.argv[1], "r") as f:
|
|
data = list(map(process_raw_line, f.readlines()))
|
|
|
|
df = pd.DataFrame(data)
|
|
df.columns = ["frame", "Y", "U", "V", "All", "dB"]
|
|
df["inv"] = [1 - value for value in df["All"]]
|
|
|
|
print(f'Mean overall SSIM: {df["All"].mean()}')
|
|
print(f'Median overall SSIM: {df["All"].median()}')
|
|
print(f'Frame with worst SSIM: {df.idxmin()["All"]+1}')
|
|
print(f'Frame with best SSIM: {df.idxmax()["All"]+1}')
|
|
|
|
print(
|
|
tabulate(
|
|
[
|
|
(key, value * 100)
|
|
for key, value in [
|
|
["best", df["All"].max()],
|
|
[50, 1 - df["inv"].quantile(0.50)],
|
|
[66.6, 1 - df["inv"].quantile(0.666)],
|
|
[75, 1 - df["inv"].quantile(0.75)],
|
|
[80, 1 - df["inv"].quantile(0.80)],
|
|
[90, 1 - df["inv"].quantile(0.90)],
|
|
[95, 1 - df["inv"].quantile(0.95)],
|
|
[98, 1 - df["inv"].quantile(0.98)],
|
|
[99, 1 - df["inv"].quantile(0.99)],
|
|
[99.9, 1 - df["inv"].quantile(0.999)],
|
|
[100, df["All"].min()],
|
|
]
|
|
],
|
|
headers=["% Frames", "≥ SSIM"],
|
|
)
|
|
)
|