<reponame>boringlee24/sevir_challenges
import pdb
import json
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import pandas
import sys

ref1 = 3724
data1 = np.array([3478, 3406.0, 3201.0, 3078.0, 2965.0])
x1 = [140, 142, 144, 146, 148]
pwr_save = (ref1 - data1) / ref1 * 100

ref2 = 270.1
data2 = np.array([287.2, 297.6, 313.5, 330.0, 340.4])
qps_gain = (data2 - ref2) / ref2 * 100

models = ['U-Net', 'YOLOv3']
colors = ['royalblue', 'gold']

fig, axs = plt.subplots(1, 1, figsize=(3.5,3.5), gridspec_kw={'hspace': 0, 'wspace': 0.3, 'top': 0.95, 'left':0.2, 'right':0.99, 'bottom':0.1})

axs.plot(x[0], data1[0], width=width, label=labels[0], edgecolor='black', linewidth=1.5, zorder=3, color=colors[0])
axs.bar(x[1], data1[1], width=width, label=labels[1], edgecolor='black', linewidth=1.5, zorder=3, color=colors[1])

axs.set_xticks(x)
xlabel = ['P100 only', 'T4 + P100']
axs.set_xticklabels(xlabel, fontsize=14)
axs.set_ylabel('Throughput (QPS)', fontsize=14)
#autolabel(rect, axs[0])
axs.set_ylim(0,480)
axs.grid(which='major', axis='y', ls='dotted')
axs.legend(fontsize=14)
axs.tick_params(axis='y', which='major', labelsize=14)

plt.savefig(f'plots/eval_3a.pdf', bbox_inches='tight')

################

ref1 = 5735
data1 = [5008.0, 4352.0, 3653.0, 2926.0]
x1 = [1600, 1700, 1800, 1900]

labels = ['27 P100', '36 T4 + 13 P100']

fig, axs = plt.subplots(1, 1, figsize=(3.5,3.5), gridspec_kw={'hspace': 0, 'wspace': 0.3, 'top': 0.95, 'left':0.2, 'right':0.99, 'bottom':0.1})

width = 0.4

rect1=axs.bar(x[0], data2[0], width=width, label=labels[0], edgecolor='black', linewidth=1.5, zorder=3, color=colors[0])
rect2=axs.bar(x[1], data2[1], width=width, label=labels[1], edgecolor='black', linewidth=1.5, zorder=3, color=colors[1])

autolabel(rect1,axs)
autolabel(rect2,axs)

axs.set_xticks(x)
axs.set_xticklabels(xlabel, fontsize=14)
axs.set_ylabel('Throughput (QPS)', fontsize=14)
#autolabel(rect, axs[0])
axs.set_ylim(0,43)
axs.grid(which='major', axis='y', ls='dotted')
axs.legend(fontsize=14)
axs.tick_params(axis='y', which='major', labelsize=14)

plt.savefig(f'plots/eval_3b.pdf', bbox_inches='tight')


import pdb
import json
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import pandas
import sys

ref1 = 3724
data1 = np.array([3478, 3406.0, 3201.0, 3078.0, 2965.0])
x1 = [140, 142, 144, 146, 148]
pwr_save = (ref1 - data1) / ref1 * 100

ref2 = 270.1
data2 = np.array([287.2, 297.6, 313.5, 330.0, 340.4])
qps_gain = (data2 - ref2) / ref2 * 100

models = ['U-Net', 'YOLOv3']
colors = ['royalblue', 'gold']

fig, axs = plt.subplots(1, 1, figsize=(3.5,3.5), gridspec_kw={'hspace': 0, 'wspace': 0.3, 'top': 0.95, 'left':0.2, 'right':0.99, 'bottom':0.1})

axs.plot(x[0], data1[0], width=width, label=labels[0], edgecolor='black', linewidth=1.5, zorder=3, color=colors[0])
axs.bar(x[1], data1[1], width=width, label=labels[1], edgecolor='black', linewidth=1.5, zorder=3, color=colors[1])

axs.set_xticks(x)
xlabel = ['P100 only', 'T4 + P100']
axs.set_xticklabels(xlabel, fontsize=14)
axs.set_ylabel('Throughput (QPS)', fontsize=14)
#autolabel(rect, axs[0])
axs.set_ylim(0,480)
axs.grid(which='major', axis='y', ls='dotted')
axs.legend(fontsize=14)
axs.tick_params(axis='y', which='major', labelsize=14)

plt.savefig(f'plots/eval_3a.pdf', bbox_inches='tight')

################

ref1 = 5735
data1 = [5008.0, 4352.0, 3653.0, 2926.0]
x1 = [1600, 1700, 1800, 1900]

labels = ['27 P100', '36 T4 + 13 P100']

fig, axs = plt.subplots(1, 1, figsize=(3.5,3.5), gridspec_kw={'hspace': 0, 'wspace': 0.3, 'top': 0.95, 'left':0.2, 'right':0.99, 'bottom':0.1})

width = 0.4

rect1=axs.bar(x[0], data2[0], width=width, label=labels[0], edgecolor='black', linewidth=1.5, zorder=3, color=colors[0])
rect2=axs.bar(x[1], data2[1], width=width, label=labels[1], edgecolor='black', linewidth=1.5, zorder=3, color=colors[1])

autolabel(rect1,axs)
autolabel(rect2,axs)

axs.set_xticks(x)
axs.set_xticklabels(xlabel, fontsize=14)
axs.set_ylabel('Throughput (QPS)', fontsize=14)
#autolabel(rect, axs[0])
axs.set_ylim(0,43)
axs.grid(which='major', axis='y', ls='dotted')
axs.legend(fontsize=14)
axs.tick_params(axis='y', which='major', labelsize=14)

plt.savefig(f'plots/eval_3b.pdf', bbox_inches='tight')
#autolabel(rect, axs[0]) ################ #autolabel(rect, axs[0])