Skip to content

Commit

Permalink
Fix for nan mean vmaf
Browse files Browse the repository at this point in the history
  • Loading branch information
master-of-zen committed May 19, 2020
1 parent 6984fbe commit c0e7223
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions av1an.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ def read_vmaf_xml(file):
vmf = i[i.rfind('="') + 2: i.rfind('"')]
vmafs.append(float(vmf))

vmafs = [round(float(x), 3) for x in vmafs if type(x) == float]
vmafs = [round(float(x), 5) for x in vmafs if type(x) == float]

# Data
x = [x for x in range(len(vmafs))]
mean = round(sum(vmafs) / len(vmafs), 3)

calc = [x for x in vmafs if isinstance(x, float) and not isnan(x)]
perc_1 = round(np.percentile(calc, 1), 3)
perc_25 = round(np.percentile(calc, 25), 3)
perc_75 = round(np.percentile(calc, 75), 3)
mean = round(sum(calc) / len(calc), 2)
perc_1 = round(np.percentile(calc, 1), 2)
perc_25 = round(np.percentile(calc, 25), 2)
perc_75 = round(np.percentile(calc, 75), 2)

return x, vmafs, mean, perc_1, perc_25, perc_75

Expand Down Expand Up @@ -715,7 +716,7 @@ def plot_vmaf(self):
plt.plot(x, vmafs, label=f'Frames: {len(vmafs)}\nMean:{mean}'
f'\n1%: {perc_1} \n25%: {perc_25} \n75%: {perc_75}', linewidth=0.7)
plt.ylabel('VMAF')
plt.legend(loc="lower right")
plt.legend(loc="lower right", markerscale=0, handlelength=0, fancybox=True, )
plt.ylim(int(perc_1), 100)
plt.tight_layout()
plt.margins(0)
Expand All @@ -730,8 +731,6 @@ def target_vmaf(self, source, command):
print('Target vmaf require more than 3 probes/steps')
sys.exit()



tg = self.d.get('vmaf_target')
mincq = self.d.get('min_cq')
maxcq = self.d.get('max_cq')
Expand Down

0 comments on commit c0e7223

Please sign in to comment.