File size: 1,262 Bytes
ecb2a3f | 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 | // Rows and cards for the MVTec AD section of the Official benchmark page. Pure functions so they can be tested.
const mark = interval => (!interval ? '' : interval[0] > 0 ? 'better' : interval[1] < 0 ? 'worse' : '');
export const productLabel = key => {
const text = String(key).replace(/_/g, ' ');
return text.charAt(0).toUpperCase() + text.slice(1);
};
export function mvtecCards(summary) {
return (summary?.arms || []).map(arm => ({
key: arm.key,
label: arm.label,
auroc: summary.macro_mean?.[arm.key]?.auroc,
pixel: summary.macro_mean?.[arm.key]?.pixel_auroc,
}));
}
export function mvtecRows(summary) {
const arms = (summary?.arms || []).map(arm => arm.key);
return Object.entries(summary?.categories || {}).map(([key, product]) => ({
key,
label: productLabel(key),
tests: product.n_test,
values: arms.map(arm => product.arms?.[arm]?.auroc),
pixel: product.arms?.[arms[arms.length - 1]]?.pixel_auroc,
// Clear differences from the paired bootstrap: coreset vs random memory, fine-tune vs coreset.
coreset: mark(product.differences?.['B-A']),
tuned: mark(product.differences?.['C-B']),
}));
}
export const markSymbol = value => (value === 'better' ? '▲' : value === 'worse' ? '▼' : '');
|