Spaces:
Sleeping
Sleeping
Download evaluation/plot_runtime.py from Ypeng12/visual-product-matching: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/Ypeng12/visual-product-matching/resolve/main/evaluation/plot_runtime.py
- Command line
-
hf download hf://spaces/Ypeng12/visual-product-matching/evaluation/plot_runtime.py
-
curl -L -o plot_runtime.py https://huggingface.co/spaces/Ypeng12/visual-product-matching/resolve/main/evaluation/plot_runtime.py
1.19 kB
| """Export measured runtime comparisons, including the unchanged client latency.""" | |
| import json | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| BASE=Path(__file__).resolve().parent | |
| data=json.loads((BASE/'runtime_comparison.json').read_text()) | |
| fig,axes=plt.subplots(1,2,figsize=(9,3.6)) | |
| for ax,metric,title in zip(axes,['server_ms','client_ms'],['Server processing','Client API call']): | |
| positions=np.arange(2) | |
| for offset,label,color in [(-.18,'before','#94a3b8'),(.18,'after','#0d9488')]: | |
| values=[data[label][metric][q] for q in ['p50','p95']] | |
| bars=ax.bar(positions+offset,values,.34,color=color,label=label.title()) | |
| ax.bar_label(bars,fmt='%.1f',fontsize=9,padding=3) | |
| ax.set_xticks(positions,['p50','p95']);ax.set_ylabel('Milliseconds');ax.set_title(title) | |
| ax.set_ylim(0,max(data['before'][metric]['p95'],data['after'][metric]['p95'])*1.22) | |
| ax.spines[['top','right']].set_visible(False);ax.legend(fontsize=8) | |
| fig.suptitle('Repeated images · 24 calls per version · CPU Basic',fontsize=11) | |
| fig.tight_layout();fig.savefig(BASE/'runtime_evaluation.png',dpi=180);plt.close(fig) | |