Download frontend/src/BenchmarkReport.jsx from Wizzas/DefectRAG: direct link, hf CLI and curl.
- Browser
- Download file 8.56 kB
-
https://huggingface.co/Wizzas/DefectRAG/resolve/main/frontend/src/BenchmarkReport.jsx
- Command line
-
hf download hf://Wizzas/DefectRAG/frontend/src/BenchmarkReport.jsx
-
curl -L -o BenchmarkReport.jsx https://huggingface.co/Wizzas/DefectRAG/resolve/main/frontend/src/BenchmarkReport.jsx
8.56 kB
| import React from 'react'; | |
| import {FlaskConical,BookOpen,ShieldCheck,ArrowUpRight} from 'lucide-react'; | |
| import {markSymbol,mvtecCards,mvtecRows} from './mvtec.mjs'; | |
| const value=n=>typeof n==='number'?n.toFixed(3):'—'; | |
| const percent=n=>typeof n==='number'?(n*100).toFixed(2)+'%':'—'; | |
| export default function BenchmarkReport({report,labels}){ | |
| const candidate=report?.candidate; | |
| const selected=candidate||report; | |
| const categories=Object.entries(selected?.categories||{}); | |
| const complete=categories.length===12; | |
| const mvtec=report?.mvtec,cards=mvtecCards(mvtec),rows=mvtecRows(mvtec); | |
| const metrics=selected?.macro_mean; | |
| const columns=['auroc','au_pr','pixel_auroc','pixel_au_pr']; | |
| return <><section className="card"><h2>Official benchmark: DINOv2 on VisA</h2><p>This page shows the official-split benchmark of the first DINOv2 profile (frozen encoder, random-sample memory), averaged over three fixed seeds. The deployed detector, with a fine-tuned encoder and a coreset memory, is described on Model performance together with the app’s operating settings.{mvtec&&' A one-run check on a second dataset, MVTec AD, follows the VisA results.'}</p><p>These tests compare inspection results on example product photos. They help explain strengths and limits, but do not approve a product or guarantee a correct result.</p><p>Image results measure whether unusual photos were found. Highlighted-area results measure where differences were located. The measured results and test settings are shown below.</p></section> | |
| <section className="card benchmark-intro"><div><span className="eyebrow">REPRODUCIBLE MODEL COMPARISON</span><h2>Measure improvement across every product.</h2><p>Official VisA training normals and test assignments. Three fixed seeds; every category reported. These are retrospective development results: earlier test data was already seen.</p></div><FlaskConical size={48}/></section> | |
| <div className="stats-grid">{[[percent(metrics?.auroc),'Mean image AUROC · headline'],[percent(metrics?.au_pr),'Mean image AU-PR'],[percent(metrics?.pixel_auroc),'Mean pixel AUROC'],[percent(metrics?.pixel_au_pr),'Mean pixel AU-PR']].map(([n,t])=><section className="card stat" key={t}><span>{t}</span><strong>{n}</strong><small>{complete?'Equal category weights · 3 seeds':'Available after all 12 finish'}</small></section>)}</div> | |
| <section className="card"><div className="section-title"><div><h2>Benchmark results by product</h2><p>Mean ± sample standard deviation over seeds 42, 43 and 44. {categories.length}/12 categories completed.</p></div><span className="subtle-tag">{complete?'COMPLETE':'IN PROGRESS'}</span></div> | |
| <div className="table-wrap"><table><thead><tr><th>Product</th><th>Train normals</th><th>Test images</th><th>Image AUROC</th><th>Image AU-PR</th><th>Pixel AUROC</th><th>Pixel AU-PR</th></tr></thead><tbody>{categories.map(([key,c])=><tr key={key}><td><strong>{labels[key]||key}</strong></td><td>{c.official_train_normals}</td><td>{c.official_test_images}</td>{columns.map(metric=><td key={metric}>{value(c.benchmark_mean[metric])}<small>± {value(c.benchmark_std[metric])}</small></td>)}</tr>)}</tbody></table></div> | |
| <p className="caption">Supplementary: mean image AP {percent(metrics?.average_precision)} · mean pixel AP {percent(metrics?.pixel_average_precision)}. These are not bounding-box mAP@IoU.</p><div className="note"><ShieldCheck size={19}/><p>Custom AnomalyDINO-inspired adaptation: frozen DINOv2 ViT-S/14, 448px short edge, rectangular patches, PCA foreground heuristic and a larger normal memory. It does not reproduce Dinomaly. Pixel evaluation uses 224×224 maps. The Model performance page describes the active deployment profile and its separate calibrated threshold.</p></div> | |
| </section> | |
| {mvtec&&<section className="card"><div className="section-title"><div><h2>MVTec AD: one-run generalisation check</h2><p>{mvtec.scope}</p></div><span className="subtle-tag">OFFLINE · ONE RUN</span></div> | |
| <div className="stats-grid plain">{cards.map(c=><section className="card stat" key={c.key}><span>{c.label}</span><strong>{percent(c.auroc)}</strong><small>Mean image AUROC · {mvtec.products} products</small></section>)}<section className="card stat"><span>Test photos</span><strong>{mvtec.test_images?.toLocaleString?.()}</strong><small>Scored once, nothing adjusted afterwards</small></section></div> | |
| <div className="table-wrap"><table><thead><tr><th>Product</th><th>Test images</th>{cards.map(c=><th key={c.key}>{c.label}</th>)}<th>Pixel AUROC</th></tr></thead><tbody>{rows.map(r=><tr key={r.key}><td><strong>{r.label}</strong></td><td>{r.tests}</td>{r.values.map((v,i)=><td key={i}>{value(v)}{i===1&&r.coreset&&<span style={{marginLeft:6}} title={r.coreset==='better'?'Clearly better than the random-sample memory':'Clearly worse than the random-sample memory'}>{markSymbol(r.coreset)}</span>}{i===2&&r.tuned&&<span style={{marginLeft:6}} title={r.tuned==='better'?'Clearly better than the coreset alone':'Clearly worse than the coreset alone'}>{markSymbol(r.tuned)}</span>}</td>)}<td>{value(r.pixel)}</td></tr>)}</tbody></table></div> | |
| <p className="caption">▲ ▼ mark a difference whose 95% bootstrap interval excludes zero: the coreset column against the random-sample memory, the last variant against the coreset alone. Pixel AUROC is for the last variant (224×224 maps) and is weak on texture products because of the foreground heuristic.</p> | |
| <div className="note"><ShieldCheck size={19}/><p>The coreset memory transfers: it is clearly better on {mvtec.comparisons?.['B-A']?.better} products and clearly worse on {mvtec.comparisons?.['B-A']?.worse}. The encoder fine-tuned on VisA adds nothing measurable here ({mvtec.comparisons?.['C-B']?.better} clearly better, {mvtec.comparisons?.['C-B']?.worse} clearly worse), so its small VisA gain is not confirmed elsewhere. MVTec AD is licensed CC BY-NC-SA 4.0, used here only for this evaluation and not redistributed; the copy came from a third-party mirror and was checked against the published counts. <a href={mvtec.protocol_url} target="_blank" rel="noreferrer">Protocol and results</a></p></div> | |
| </section>} | |
| <section className="card"><div className="section-title"><div><h2>Overall evaluation metrics</h2><p>The official VisA protocol reports AUROC and AU-PR, averaged across products. Image metrics evaluate detection; pixel metrics evaluate localization.</p></div><BookOpen size={22}/></div><div className="training-steps">{[ | |
| ['01','Mean image AUROC','For each product, measure how well scores rank anomalous images above normal images; average the 12 category AUROCs. 0.5 is chance-level ranking.'], | |
| ['02','Supplementary mean image AP','Calculate average precision for anomaly detection in each product category, then average across all 12. This is not YOLO mAP@0.5 or mAP@0.5:0.95: we do not predict boxes or named defect classes.'], | |
| ['03','Supplementary mean pixel AP','Calculate pixel average precision within each category, including normal images, then average over products. It measures localization; high image AP does not guarantee accurate heatmaps.'], | |
| ['04','Mean image AU-PR','Trapezoidal area under each precision–recall curve, averaged over products. It follows the official VisA metric implementation and is distinct from non-interpolated average precision.'], | |
| ['05','Normal-only fitting and calibration','The published benchmark below uses the frozen pretrained encoder; the online detector uses a lightly fine-tuned DINOv2 (see the model card). Normal images populate memory. A separate operational bank holds out normal training images to calibrate its threshold; no test anomalies select that threshold.'], | |
| ['06','Evaluation limits','Configuration is fixed before each candidate run, but earlier test results informed this development effort. Report it as retrospective benchmarking, not an untouched external evaluation.'] | |
| ].map(([n,t,d])=><details key={n}><summary><span>{n}</span><strong>{t}</strong></summary><p>{d}</p></details>)}</div><div className="button-row"><a className="secondary" href="https://github.com/amazon-science/spot-diff" target="_blank" rel="noreferrer">Official VisA protocol <ArrowUpRight size={15}/></a><a className="secondary" href="https://github.com/dammsi/AnomalyDINO" target="_blank" rel="noreferrer">AnomalyDINO reference <ArrowUpRight size={15}/></a></div><p className="caption">Exact settings, differences from the paper and resume commands are in docs/TRAINING_AND_EVALUATION.md.</p></section> | |
| </>; | |
| } | |