"<!DOCTYPE html>\n<html lang=\"zh\" data-theme=\"light\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>fulltext.txt — Vercel Design System</title>\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap\" rel=\"stylesheet\">\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css\">\n<style>\n\n:root {\n  /* Vercel Palette */\n  --geist-foreground: #171717;\n  --geist-background: #ffffff;\n  --geist-secondary: #4d4d4d;\n  --geist-tertiary: #666666;\n  --geist-quaternary: #808080;\n  --geist-border: #ebebeb;\n  --geist-surface-tint: #fafafa;\n  \n  /* Workflow Accents */\n  --develop-blue: #0a72ef;\n  --preview-pink: #de1d8d;\n  --ship-red: #ff5b4f;\n  \n  /* Interactive & Status */\n  --link-blue: #0072f5;\n  --ds-focus-color: hsla(212, 100%, 48%, 1);\n  --badge-blue-bg: #ebf5ff;\n  --badge-blue-text: #0068d6;\n  \n  /* Shadow-as-Border Philosophy */\n  --shadow-border: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(0, 0, 0, 0.16) 0px 0px 0px 1px;\n  --shadow-card: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(0, 0, 0, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.06) 0px 4px 6px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-full: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, rgba(0, 0, 0, 0.04) 0px 8px 8px -8px, #fafafa 0px 0px 0px 1px;\n  --shadow-ring: rgb(235, 235, 235) 0px 0px 0px 1px;\n  \n  /* Radius Scale */\n  --radius-xs: 2px;\n  --radius-sm: 4px;\n  --radius-md: 6px;\n  --radius-lg: 8px;\n  --radius-xl: 12px;\n  --radius-pill: 9999px;\n}\n\n[data-theme=\"dark\"] {\n  --geist-foreground: #ededed;\n  --geist-background: #000000;\n  --geist-secondary: #a1a1a1;\n  --geist-tertiary: #888888;\n  --geist-quaternary: #666666;\n  --geist-border: #222222;\n  --geist-surface-tint: #0a0a0a;\n  \n  --shadow-border: rgba(255, 255, 255, 0.14) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(255, 255, 255, 0.28) 0px 0px 0px 1px;\n  --shadow-card: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.4) 0px 2px 4px, #111111 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(255, 255, 255, 0.2) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 6px 12px, #111111 0px 0px 0px 1px;\n  --shadow-card-full: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 8px 16px -4px, #111111 0px 0px 0px 1px;\n  --shadow-ring: rgb(40, 40, 40) 0px 0px 0px 1px;\n  \n  --badge-blue-bg: rgba(10, 114, 239, 0.15);\n  --badge-blue-text: #70b5ff;\n}\n\n* { box-sizing: border-box; }\nhtml { scroll-behavior: smooth; }\nbody {\n  margin: 0;\n  font-family: \"Geist\", Arial, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n  background-color: var(--geist-background);\n  color: var(--geist-foreground);\n  font-feature-settings: \"liga\" 1;\n  -webkit-font-smoothing: antialiased;\n  min-height: 100vh;\n}\n\na {\n  color: inherit;\n  text-decoration: none;\n  transition: color 0.15s ease;\n}\n\n/* 导航栏 (Vercel Clean Sticky Nav) */\n.vercel-nav {\n  position: sticky;\n  top: 0;\n  background-color: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  z-index: 100;\n  padding: 0 24px;\n  height: 64px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n.nav-brand {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n.vercel-triangle {\n  width: 22px;\n  height: 19px;\n  fill: var(--geist-foreground);\n}\n.nav-title {\n  font-size: 16px;\n  font-weight: 600;\n  letter-spacing: -0.32px;\n  color: var(--geist-foreground);\n}\n.nav-badge-pill {\n  font-family: \"Geist Mono\", ui-monospace, monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  background: var(--badge-blue-bg);\n  color: var(--badge-blue-text);\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n}\n\n.nav-links {\n  display: flex;\n  align-items: center;\n  gap: 24px;\n}\n.nav-link {\n  font-size: 14px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.nav-link:hover, .nav-link.active {\n  color: var(--geist-foreground);\n}\n.nav-link.active {\n  font-weight: 600;\n}\n\n.nav-actions {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n/* 按钮规范 */\n.btn-primary-dark {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: opacity 0.15s;\n}\n.btn-primary-dark:hover {\n  opacity: 0.9;\n}\n.btn-secondary-white {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: background 0.15s, box-shadow 0.15s;\n}\n.btn-secondary-white:hover {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border-hover);\n}\n.theme-toggle-btn {\n  background: transparent;\n  border: none;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  width: 36px;\n  height: 36px;\n  cursor: pointer;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  color: var(--geist-foreground);\n}\n\n/* 核心容器 */\n.vercel-container {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 56px 24px 100px;\n}\n\n/* Hero Section (Gallery Emptiness + Negative Letter-spacing) */\n.vercel-hero {\n  text-align: center;\n  max-width: 860px;\n  margin: 0 auto 56px;\n}\n.hero-stage-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 4px 14px;\n  border-radius: var(--radius-pill);\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  margin-bottom: 24px;\n}\n.stage-dot {\n  width: 7px;\n  height: 7px;\n  border-radius: 50%;\n}\n.vercel-hero h1 {\n  font-size: 48px;\n  font-weight: 600;\n  line-height: 1.05;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 16px;\n}\n.vercel-hero p {\n  font-size: 20px;\n  font-weight: 400;\n  line-height: 1.80;\n  color: var(--geist-secondary);\n  margin: 0 auto 28px;\n}\n\n/* Workflow Pipeline (Develop -> Preview -> Ship) */\n.workflow-pipeline {\n  display: grid;\n  grid-template-columns: repeat(3, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 768px) {\n  .workflow-pipeline { grid-template-columns: 1fr; }\n}\n.workflow-step {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px 22px;\n  transition: box-shadow 0.2s;\n}\n.workflow-step:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n.step-mono-label {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  margin-bottom: 8px;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n.step-title {\n  font-size: 20px;\n  font-weight: 600;\n  letter-spacing: -0.96px;\n  color: var(--geist-foreground);\n  margin-bottom: 6px;\n}\n.step-desc {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n\n/* Metric Cards (Section 4 Spec) */\n.metric-grid {\n  display: grid;\n  grid-template-columns: repeat(4, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 900px) {\n  .metric-grid { grid-template-columns: repeat(2, 1fr); }\n}\n.metric-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n}\n.metric-number {\n  font-size: 40px;\n  font-weight: 600;\n  line-height: 1.0;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin-bottom: 8px;\n  font-feature-settings: \"tnum\" 1;\n}\n.metric-label {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.4;\n}\n\n/* VAD 专栏 Banner (Ship Red & Vercel Clean) */\n.vad-showcase {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-xl);\n  padding: 32px;\n  margin-bottom: 48px;\n  position: relative;\n}\n.vad-header-row {\n  display: flex;\n  align-items: baseline;\n  justify-content: space-between;\n  flex-wrap: wrap;\n  gap: 12px;\n  margin-bottom: 12px;\n}\n.vad-header-row h2 {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  color: var(--geist-foreground);\n  margin: 0;\n}\n.vad-pillars-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));\n  gap: 14px;\n  margin-top: 24px;\n}\n.vad-pillar-item {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 14px 16px;\n}\n.vad-pillar-title {\n  font-size: 14px;\n  font-weight: 600;\n  color: var(--ship-red);\n  margin-bottom: 4px;\n}\n.vad-pillar-text {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n.vad-filter-bar {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  margin: 24px 0 16px;\n  padding: 12px 16px;\n  background: var(--geist-surface-tint);\n  border-radius: var(--radius-md);\n  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);\n}\n.vad-filter-btn {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  font-weight: 500;\n  padding: 6px 14px;\n  border-radius: 9999px;\n  border: none;\n  background: transparent;\n  color: var(--geist-secondary);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.vad-filter-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0,0,0,0.05);\n}\n.vad-filter-btn.active {\n  background: #171717;\n  color: #ffffff;\n}\n.vad-search-input {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  padding: 7px 12px;\n  border-radius: 6px;\n  border: 1px solid var(--geist-border);\n  background: #ffffff;\n  color: var(--geist-foreground);\n  width: 280px;\n  outline: none;\n  transition: border-color 0.15s, box-shadow 0.15s;\n}\n.vad-search-input:focus {\n  border-color: #0a72ef;\n  box-shadow: 0 0 0 2px rgba(10, 114, 239, 0.2);\n}\n\n/* 控制栏：搜索、视图、筛选 */\n.control-bar {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  margin-bottom: 24px;\n  flex-wrap: wrap;\n}\n.search-input-wrap {\n  position: relative;\n  flex: 1;\n  max-width: 480px;\n}\n.search-input {\n  width: 100%;\n  height: 40px;\n  padding: 0 38px 0 14px;\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  color: var(--geist-foreground);\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  outline: none;\n  transition: box-shadow 0.15s;\n}\n.search-input:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n.search-kbd {\n  position: absolute;\n  right: 12px;\n  top: 50%;\n  transform: translateY(-50%);\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  color: var(--geist-quaternary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n\n.view-switcher {\n  display: flex;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  background: var(--geist-background);\n  padding: 2px;\n}\n.view-btn {\n  background: transparent;\n  border: none;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-tertiary);\n  padding: 6px 12px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n  transition: color 0.15s, background 0.15s;\n}\n.view-btn.active {\n  background: var(--geist-surface-tint);\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 筛选芯片行 (Filter Pill Strip) */\n.filter-group-strip {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n  margin-bottom: 28px;\n  padding: 16px 20px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-lg);\n}\n.filter-row {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  flex-wrap: wrap;\n}\n.filter-label-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  min-width: 68px;\n}\n.pill-badge {\n  background: var(--geist-background);\n  color: var(--geist-secondary);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 3px 12px;\n  border-radius: var(--radius-pill);\n  font-size: 12px;\n  font-weight: 500;\n  cursor: pointer;\n  transition: all 0.15s;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n}\n.pill-badge:hover {\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border-hover);\n}\n.pill-badge.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  font-weight: 600;\n  box-shadow: none;\n}\n.pill-badge.active-blue {\n  background: var(--develop-blue);\n  color: #ffffff;\n  box-shadow: none;\n}\n.pill-badge.active-red {\n  background: var(--ship-red);\n  color: #ffffff;\n  box-shadow: none;\n}\n\n/* Bento Grid Cards (Section 4 & 6 Spec) */\n.card-grid-bento {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n  gap: 16px;\n}\n.vercel-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  transition: box-shadow 0.2s, transform 0.2s;\n  text-decoration: none;\n  color: inherit;\n  overflow: hidden;\n  min-width: 0;\n  word-break: break-word;\n}\n.vercel-card:hover {\n  box-shadow: var(--shadow-card-hover);\n  transform: translateY(-2px);\n}\n.card-top {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  margin-bottom: 12px;\n  gap: 8px;\n}\n.card-tag-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  letter-spacing: 0.5px;\n}\n.status-pill-badge {\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 500;\n  flex-shrink: 0;\n}\n.pub-accepted { background: #ebfdf2; color: #027a48; }\n.pub-workshop { background: #eff8ff; color: #175cd3; }\n.pub-submitted { background: #fff8e6; color: #b54708; }\n.pub-preprint { background: #f2f4f7; color: #475467; }\n.pub-other { background: #f9f5ff; color: #6941c6; }\n\n[data-theme=\"dark\"] .pub-accepted { background: rgba(2, 122, 72, 0.2); color: #32d583; }\n[data-theme=\"dark\"] .pub-workshop { background: rgba(23, 92, 211, 0.2); color: #84caff; }\n[data-theme=\"dark\"] .pub-submitted { background: rgba(181, 71, 8, 0.2); color: #fec84b; }\n[data-theme=\"dark\"] .pub-preprint { background: rgba(71, 84, 103, 0.2); color: #98a2b3; }\n[data-theme=\"dark\"] .pub-other { background: rgba(105, 65, 198, 0.2); color: #d6bbfb; }\n\n/* 必读标杆徽章 (Vercel Amber Accent) */\n.milestone-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 3px;\n  padding: 2px 7px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 600;\n  white-space: nowrap;\n  flex-shrink: 0;\n  transition: all 0.15s ease;\n}\n.milestone-badge.ms-idea, .milestone-badge:not([class*=\"ms-\"]) {\n  color: #b54708;\n  background: #fff8e6;\n  border: 1px solid rgba(247, 144, 9, 0.35);\n  box-shadow: 0 1px 2px rgba(181, 71, 8, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-idea, [data-theme=\"dark\"] .milestone-badge:not([class*=\"ms-\"]) {\n  color: #fec84b;\n  background: rgba(181, 71, 8, 0.22);\n  border-color: rgba(254, 200, 75, 0.35);\n}\n.milestone-badge.ms-writing {\n  color: #6941c6;\n  background: #f9f5ff;\n  border: 1px solid rgba(105, 65, 198, 0.3);\n  box-shadow: 0 1px 2px rgba(105, 65, 198, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-writing {\n  color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.22);\n  border-color: rgba(214, 187, 251, 0.35);\n}\n.milestone-badge.ms-value {\n  color: #027a48;\n  background: #ebfdf2;\n  border: 1px solid rgba(2, 122, 72, 0.3);\n  box-shadow: 0 1px 2px rgba(2, 122, 72, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-value {\n  color: #32d583;\n  background: rgba(2, 122, 72, 0.22);\n  border-color: rgba(50, 213, 131, 0.35);\n}\n\n/* 论文正文图表与插图卡片样式 (Geist Design) */\n.paper-figure, .article-body figure {\n  margin: 32px auto;\n  text-align: center;\n  max-width: 100%;\n}\n.paper-figure img, .article-body img {\n  max-width: 96%;\n  height: auto;\n  border-radius: var(--radius-md);\n  border: 1px solid var(--geist-border);\n  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);\n  background: #ffffff;\n  transition: transform 0.2s ease, box-shadow 0.2s ease;\n  display: block;\n  margin: 0 auto;\n}\n.paper-figure img:hover, .article-body img:hover {\n  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);\n}\n.paper-figure figcaption, .article-body figcaption {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  margin-top: 10px;\n  line-height: 1.6;\n  font-style: italic;\n  max-width: 850px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n/* VAD 视图切换器 View Switcher */\n.vad-view-switcher {\n  display: inline-flex;\n  padding: 3px;\n  background: var(--geist-secondary-bg);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  margin-bottom: 20px;\n  gap: 2px;\n}\n.view-switch-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 6px 14px;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  border-radius: 6px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.view-switch-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0, 0, 0, 0.04);\n}\n[data-theme=\"dark\"] .view-switch-btn:hover {\n  background: rgba(255, 255, 255, 0.06);\n}\n.view-switch-btn.active {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  font-weight: 600;\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n/* 关系图谱 Graph View Styles */\n.graph-container {\n  position: relative;\n  width: 100%;\n  height: 720px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: var(--radius-lg);\n  overflow: hidden;\n  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);\n  margin-bottom: 40px;\n}\n.graph-toolbar {\n  position: absolute;\n  top: 14px;\n  left: 14px;\n  right: 14px;\n  z-index: 10;\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  padding: 8px 14px;\n  border-radius: 8px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  flex-wrap: wrap;\n  gap: 8px;\n}\n.graph-tool-title {\n  font-size: 13px;\n  font-weight: 700;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  color: var(--geist-foreground);\n}\n.graph-filter-group {\n  display: flex;\n  gap: 6px;\n  align-items: center;\n  flex-wrap: wrap;\n}\n.graph-chip {\n  font-size: 11px;\n  padding: 3px 8px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.graph-chip:hover { background: var(--geist-secondary-bg); }\n.graph-chip.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-color: var(--geist-foreground);\n}\n.graph-search-input {\n  padding: 3px 8px;\n  font-size: 11px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  outline: none;\n  width: 150px;\n}\n#vad-graph-svg {\n  width: 100%;\n  height: 100%;\n  cursor: grab;\n}\n#vad-graph-svg:active { cursor: grabbing; }\n.graph-legend {\n  position: absolute;\n  bottom: 14px;\n  left: 14px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  padding: 10px 14px;\n  font-size: 11px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  z-index: 10;\n  line-height: 1.6;\n  pointer-events: none;\n}\n.graph-legend-row { display: flex; align-items: center; gap: 8px; }\n.graph-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }\n.graph-info-drawer {\n  position: absolute;\n  top: 66px;\n  right: 14px;\n  width: 310px;\n  max-height: 620px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  box-shadow: 0 8px 30px rgba(0,0,0,0.12);\n  z-index: 10;\n  padding: 16px;\n  overflow-y: auto;\n  display: none;\n  backdrop-filter: blur(10px);\n  transition: transform 0.2s ease, opacity 0.2s ease;\n}\n.graph-drawer-close {\n  position: absolute;\n  top: 10px;\n  right: 12px;\n  cursor: pointer;\n  font-size: 16px;\n  color: var(--geist-tertiary);\n}\n.graph-drawer-badge {\n  display: inline-block;\n  padding: 2px 6px;\n  border-radius: 4px;\n  font-size: 10px;\n  font-weight: 600;\n  margin-bottom: 6px;\n}\n.graph-drawer-title {\n  font-size: 13px;\n  font-weight: 700;\n  line-height: 1.4;\n  margin-bottom: 8px;\n  color: var(--geist-foreground);\n}\n.graph-drawer-meta {\n  font-size: 11px;\n  color: var(--geist-secondary);\n  margin-bottom: 12px;\n}\n.graph-drawer-core {\n  font-size: 12px;\n  line-height: 1.6;\n  color: var(--geist-foreground);\n  background: var(--geist-secondary-bg);\n  padding: 8px 10px;\n  border-radius: 6px;\n  margin-bottom: 12px;\n  border: 1px solid var(--geist-border);\n}\n.graph-drawer-link {\n  display: block;\n  text-align: center;\n  padding: 7px 12px;\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-radius: 6px;\n  font-size: 12px;\n  font-weight: 600;\n  text-decoration: none;\n  transition: opacity 0.15s ease;\n  margin-bottom: 6px;\n}\n.graph-drawer-link:hover { opacity: 0.85; }\n.graph-drawer-pdf-link {\n  display: block;\n  text-align: center;\n  padding: 6px 12px;\n  background: var(--geist-secondary-bg);\n  color: var(--geist-foreground);\n  border: 1px solid var(--geist-border);\n  border-radius: 6px;\n  font-size: 11px;\n  font-weight: 500;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.graph-drawer-pdf-link:hover { background: var(--geist-border); }\n.node-circle {\n  cursor: pointer;\n  transition: r 0.2s, stroke-width 0.2s;\n}\n.node-label {\n  font-size: 10px;\n  font-weight: 600;\n  fill: var(--geist-foreground);\n  pointer-events: none;\n  text-shadow: 0 1px 2px var(--geist-background);\n}\n.link-line {\n  stroke: var(--geist-border);\n  stroke-opacity: 0.6;\n  stroke-width: 1.2;\n  transition: stroke 0.2s, stroke-width 0.2s, stroke-opacity 0.2s;\n}\n.link-label {\n  font-size: 9px;\n  fill: var(--geist-tertiary);\n  pointer-events: none;\n  text-anchor: middle;\n}\n\n/* 引用框与警示框 Alerts */\n.callout-alert {\n  margin: 20px 0;\n  padding: 14px 18px;\n  border-radius: var(--radius-md);\n  transition: all 0.15s ease;\n}\n.callout-important, .callout-idea {\n  border-left: 4px solid #b54708;\n  background: rgba(181, 71, 8, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(247, 144, 9, 0.3);\n}\n[data-theme=\"dark\"] .callout-important, [data-theme=\"dark\"] .callout-idea {\n  border-left-color: #fec84b;\n  background: rgba(181, 71, 8, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(254, 200, 75, 0.25);\n}\n.callout-writing {\n  border-left: 4px solid #6941c6;\n  background: rgba(105, 65, 198, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(105, 65, 198, 0.3);\n}\n[data-theme=\"dark\"] .callout-writing {\n  border-left-color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(214, 187, 251, 0.25);\n}\n.callout-value {\n  border-left: 4px solid #027a48;\n  background: rgba(2, 122, 72, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(2, 122, 72, 0.3);\n}\n[data-theme=\"dark\"] .callout-value {\n  border-left-color: #32d583;\n  background: rgba(2, 122, 72, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(50, 213, 131, 0.25);\n}\n\n.card-title {\n  font-size: 16.5px;\n  font-weight: 600;\n  line-height: 1.42;\n  letter-spacing: -0.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 10px;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n  hyphens: auto;\n}\n.card-title a {\n  color: var(--geist-foreground);\n  text-decoration: none;\n  display: inline;\n  transition: color 0.15s ease;\n}\n.card-title a:hover {\n  color: var(--develop-blue);\n  text-decoration: none;\n}\n.card-id-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-quaternary);\n  margin-right: 5px;\n}\n.card-meta-row {\n  display: flex;\n  gap: 6px;\n  flex-wrap: wrap;\n  margin-bottom: 12px;\n}\n.meta-token {\n  font-size: 12px;\n  color: var(--geist-tertiary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-ring);\n  padding: 2px 7px;\n  border-radius: var(--radius-sm);\n  white-space: nowrap;\n}\n.card-body-text {\n  font-size: 13.5px;\n  color: var(--geist-secondary);\n  line-height: 1.6;\n  margin-bottom: 16px;\n  flex-grow: 1;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n}\n.card-body-text strong {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n.card-footer {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 14px;\n}\n.card-link-action {\n  font-size: 13.5px;\n  font-weight: 500;\n  color: var(--link-blue);\n  display: inline-flex;\n  align-items: center;\n  gap: 4px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.card-link-action:hover {\n  opacity: 0.85;\n  transform: translateX(2px);\n}\na.meta-token {\n  transition: all 0.15s ease;\n  cursor: pointer;\n  text-decoration: none;\n}\na.meta-token:hover {\n  background: var(--geist-selection);\n  color: var(--geist-foreground);\n  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);\n}\n\n/* 紧凑列表视图 (List View) */\n.card-list-view {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n}\n.list-row-item {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-md);\n  padding: 12px 18px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  transition: box-shadow 0.15s;\n}\n.list-row-item:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n\n/* 阅读详情页 (Report Detail) */\n.reading-container {\n  display: grid;\n  grid-template-columns: minmax(0, 1fr) 260px;\n  gap: 40px;\n  align-items: start;\n}\n@media (max-width: 960px) {\n  .reading-container { grid-template-columns: 1fr; }\n  .reading-sidebar { display: none; }\n}\n\n.report-header-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 28px 32px;\n  margin-bottom: 28px;\n}\n.crumb-bar {\n  font-size: 13px;\n  color: var(--geist-tertiary);\n  margin-bottom: 10px;\n}\n.report-title {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  margin: 0 0 16px;\n  color: var(--geist-foreground);\n}\n.report-action-buttons {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  flex-wrap: wrap;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 16px;\n  margin-top: 16px;\n}\n\n.article-body {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 36px 42px 80px;\n  font-size: 16px;\n  line-height: 1.75;\n  color: var(--geist-foreground);\n}\n.article-body h1, .article-body h2, .article-body h3 {\n  color: var(--geist-foreground);\n  scroll-margin-top: 80px;\n}\n.article-body h1 { font-size: 28px; font-weight: 600; letter-spacing: -1.28px; border-bottom: 1px solid var(--geist-border); padding-bottom: 8px; margin-top: 32px; }\n.article-body h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.96px; border-bottom: 1px solid var(--geist-border); padding-bottom: 6px; margin-top: 36px; }\n.article-body h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.32px; margin-top: 26px; }\n.article-body table {\n  width: 100%;\n  border-collapse: collapse;\n  margin: 24px 0;\n  font-size: 14px;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  overflow: hidden;\n}\n.article-body th, .article-body td {\n  padding: 10px 14px;\n  text-align: left;\n  border-bottom: 1px solid var(--geist-border);\n}\n.article-body th {\n  background: var(--geist-surface-tint);\n  font-weight: 600;\n  color: var(--geist-foreground);\n}\n.article-body blockquote {\n  border-left: 2px solid var(--geist-foreground);\n  margin: 20px 0;\n  padding: 8px 18px;\n  color: var(--geist-secondary);\n  font-style: normal;\n}\n.article-body code {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13.5px;\n  box-shadow: var(--shadow-ring);\n  background: var(--geist-surface-tint);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n.article-body pre {\n  position: relative;\n  background: #000000;\n  color: #ededed;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 18px;\n  margin: 24px 0;\n  overflow-x: auto;\n}\n.article-body pre code {\n  background: transparent;\n  box-shadow: none;\n  padding: 0;\n  color: inherit;\n  font-size: 13px;\n}\n.copy-code-btn {\n  position: absolute;\n  top: 8px;\n  right: 10px;\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  background: #171717;\n  color: #ffffff;\n  border: 1px solid #333333;\n  padding: 3px 8px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n}\n\n/* 侧边大纲 (TOC) */\n.reading-sidebar {\n  position: sticky;\n  top: 80px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  max-height: calc(100vh - 100px);\n  overflow-y: auto;\n}\n.sidebar-toc-title {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: var(--geist-quaternary);\n  margin-bottom: 12px;\n}\n.reading-sidebar ul {\n  list-style: none;\n  padding-left: 0;\n  margin: 0;\n  font-size: 13px;\n}\n.reading-sidebar li {\n  margin: 6px 0;\n}\n.reading-sidebar ul ul {\n  padding-left: 14px;\n}\n.reading-sidebar a {\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.reading-sidebar a:hover, .reading-sidebar a.active {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 后台管理 (/admin) */\n.admin-card-container {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 32px;\n  margin-bottom: 32px;\n}\n.form-row-2 {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 16px;\n  margin-bottom: 16px;\n}\n@media (max-width: 600px) {\n  .form-row-2 { grid-template-columns: 1fr; }\n}\n.form-field {\n  display: flex;\n  flex-direction: column;\n  gap: 6px;\n  margin-bottom: 16px;\n}\n.form-field label {\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-foreground);\n}\n.form-field input, .form-field select, .form-field textarea {\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  padding: 9px 12px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  color: var(--geist-foreground);\n  outline: none;\n}\n.form-field input:focus, .form-field select:focus, .form-field textarea:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n\n/* 语法高亮 (Console Blue / Purple / Pink) */\n.codehilite .k, .codehilite .kd, .codehilite .kn { color: #eb367f; font-weight: 500; }\n.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #0070f3; }\n.codehilite .nf, .codehilite .na { color: #7928ca; font-weight: 500; }\n.codehilite .c, .codehilite .c1 { color: #666666; font-style: italic; }\n.codehilite .mi, .codehilite .mf { color: #ff5b4f; }\n\n</style>\n\n</head>\n<body>\n\n    <nav class=\"vercel-nav\">\n      <div class=\"nav-brand\">\n        <a href=\"/\" style=\"display:flex;align-items:center;gap:10px;text-decoration:none\">\n          <svg class=\"vercel-triangle\" viewBox=\"0 0 76 65\" fill=\"none\">\n            <path d=\"M37.5274 0L75.0548 65H0L37.5274 0Z\" fill=\"currentColor\"/>\n          </svg>\n          <span class=\"nav-title\">Agent Harness KB</span>\n        </a>\n        <span class=\"nav-badge-pill\">Geist 2.0</span>\n      </div>\n\n      <div class=\"nav-links\">\n        <a class=\"nav-link \" href=\"/\">全景总览</a>\n        <a class=\"nav-link \" href=\"/vad\" style=\"color:var(--ship-red)\">🎯 VAD 专栏 (144)</a>\n        <a class=\"nav-link\" href=\"https://m0rtzz.github.io/paper-notes/\" target=\"_blank\" rel=\"noopener\">顶会 669 篇 ↗</a>\n        <a class=\"nav-link\" href=\"/download/all\">整库打包</a>\n        \n      </div>\n\n      <div class=\"nav-actions\">\n        \n        <button class=\"theme-toggle-btn\" id=\"theme-toggle-btn\" onclick=\"toggleTheme()\" title=\"切换亮暗主题\">🌙</button>\n      </div>\n    </nav>\n    \n<main class=\"vercel-container\">\n\n        <div class=\"report-header-card\">\n          <div class=\"crumb-bar\"><a href=\"/\">Home</a> / <b>fulltext.txt</b></div>\n          <h1 class=\"report-title\">fulltext.txt</h1>\n          <div class=\"report-action-buttons\">\n            <a class=\"btn-primary-dark\" href=\"?dl=1\">Download Text</a>\n          </div>\n        </div>\n        <article class=\"article-body\"><pre><code>arXiv:2410.14379v2 [cs.CV] 27 Mar 2025\n\nAnomalyNCD: Towards Novel Anomaly Class Discovery in Industrial Scenarios\nZiming Huang1,∗ Xurui Li1,∗ Haotian Liu1,∗ Feng Xue4 Yuzhe Wang1 Yu Zhou1,2,3,†\n1\nSchool of Electronic Information and Communications, Huazhong University of Science and Technology\n2\nHubei Key Laboratory of Smart Internet Technology, Huazhong University of Science and Technology\n3\nArtificial Intelligence Research Institute, Wuhan JingCe Electronic Group Co., LTD\n4\nDepartment of Information Engineering and Computer Science, University of Trento\n\nAbstract\n\nanomaly categories that are constantly emerging.\nSeveral anomaly clustering approaches [1, 28, 40] have\nbeen proposed to address the multi-class anomaly classification task, as illustrated in Fig. 1 (a). These approaches\ntypically employ a two-step process: anomaly localization\nfollowed by feature extraction from the anomalous regions\nfor clustering. However, the effectiveness of these methods is limited when dealing with homogeneous anomaly\npatterns that exhibit differences in shape, appearance, and\nlocation, primarily due to the lack of prior knowledge of\nanomaly types. Therefore, our study aims to classify unseen\nanomalies by leveraging prior knowledge of seen anomalies, thereby overcoming the limitations of current methods.\nThrough detailed investigation, we find two primary obstacles in leveraging prior knowledge of known anomalies,\nwhich prevent existing classification network to industrial\nanomalies. ❶ Non-prominence Anomalies: Classification\nin natural scenes assumes that subjects are centered in the\nimages so that networks easily extract their semantics, while\nthis assumption is not true in industrial scenarios. ❷ Lowsemantics Anomalies: In contrast to natural objects, industrial anomalies are typically less semantic, making the network hard to focus on anomalies but prone to background.\nIn this paper, we overcome both obstructions and propose a multi-class anomaly classification network that\naligns with the concept of novel class discovery (NCD),\nas illustrated in 1 (c). This network learns to classify isolated anomalies by focusing the model’s attention on real\nanomaly regions. Firstly, to address the non-prominence\nissue, we propose a main element binarization (MEBin)\nmethod. MEBin isolates the primary anomaly regions by\nextracting them from anomaly detection (AD) results. This\nbinarization process alleviates the negative impact of errors\nwithin AD results on the subsequent multi-class anomaly\nlearning, enabling compatibility with various AD algorithms. Secondly, to tackle low-semantics anomalies, we\npropose mask-guided representation learning. It leverages\nthe anomaly masks generated by MEBin to direct the network’s attention specifically to individual anomalous re-\n\nRecently, multi-class anomaly classification has garnered\nincreasing attention. Previous methods directly cluster\nanomalies but often struggle due to the lack of anomalyprior knowledge. Acquiring this knowledge faces two issues: the non-prominent and weak-semantics anomalies.\nIn this paper, we propose AnomalyNCD, a multi-class\nanomaly classification network compatible with different\nanomaly detection methods. To address the non-prominence\nof anomalies, we design main element binarization (MEBin)\nto obtain anomaly-centered images, ensuring anomalies are\nlearned while avoiding the impact of incorrect detections.\nNext, to learn anomalies with weak semantics, we design\nmask-guided representation learning, which focuses on isolated anomalies guided by masks and reduces confusion\nfrom erroneous inputs through corrected pseudo labels. Finally, to enable flexible classification at both region and image levels, we develop a region merging strategy that determines the overall image category based on the classified anomaly regions. Our method outperforms the state-ofthe-art works on the MVTec AD and MTD datasets. Compared with the current methods, AnomalyNCD combined\nwith zero-shot anomaly detection method achieves a 10.8%\nF1 gain, 8.8% NMI gain, and 9.5% ARI gain on MVTec AD,\nand 12.8% F1 gain, 5.7% NMI gain, and 10.8% ARI gain\non MTD. Code is available at https://github.com/HUSTSLOW/AnomalyNCD.\n\n1. Introduction\nIn recent years, industrial anomaly detection [22, 24, 31, 53]\nhas garnered remarkable performance. It locates visual\nanomalies on industrial products but without recognizing\nfine-grained anomaly categories. For downstream anomaly\ntreatments, it is necessary to recognize the anomaly classes,\nsuch as fracture, ablation, etc., and even discover novel\n∗ Contributed Equally. † Corresponding Author.\n\n1\n\n\fUnknown Classes\n\nUnknown Classes\n\nBird\n\nPanda …\n\nUnknown Classes\n\nBreakdown\n\n…\n\nAnomaly\nDetection\nRGB\n\nRGB\n\nDeep Feature\nExtractor\n\nRGB\n\nRGB\n\nDeep Feature\nExtractor\n\nWeight\nUnsupervised\nClustering\n\nRGB\n\nSSL\n\nPrediction\n\n(a) Anomaly Clustering\nBase classes training\nNovel classes training/inference\n\nParametric\nclassifier\n\nSL\n\nGT\n\nParametric\nclassifier\n\nInference\n\nFrozen\nTrainable\n\nSSL\n\nGT Mask\n\nSSL\nSL\n\nPrediction\n\nGT\n\n(c) AnomalyNCD\n\n(b) NCD in natural scenario\nPixel-wise multiplication\n\nRGB\n\nDetection\n\nMask-Guided\nFeature Extractor\n\nSSL\n\nPrediction\n\nRGB\n\nSL Supervised Learning\nPrediction of novel classes\n\nSSL Self-Supervised Learning\nPrediction of base classes\n\nFigure 1. Comparison between solutions organizing anomalies into groups. (a) Anomaly clustering methods extract the features of\nthe anomaly region and employ unsupervised clustering algorithms to cluster the anomalies. (b) Vanilla NCD methods typically employ\na trainable feature extractor and classifier. These components process object-centered images from both known and unknown classes. (c)\nOur method aims to learn features of isolated anomaly regions using anomaly-centered sub-images and masks from MEBin.\n\nfeatures with the higher anomaly score to determine the\nclasses. However, both methods rely on frozen models\nthat cannot learn features specific to anomalies. Therefore,\nwe adopt self-supervised learning to discover novel classes\nfrom unlabeled anomalies.\n\ngions, ensuring our network learns more discriminative features specific to anomalies and classifies each individual\nanomaly. Additionally, we use corrected pseudo labels in\nthis learning method to prevent false-positive anomalies\nfrom training. Finally, to achieve more flexible classification in both region and image levels, we propose a region\nmerging strategy, which determines the image category according to the classification of each region in the image. Experimental results on the MVTec AD [5] and MTD datasets\n[23] demonstrate the effectiveness of AnomalyNCD.\nIn summary, the major contributions of our work are:\n• We propose the first method based on self-supervised\nmanner in multi-class anomaly classification, named\nAnomalyNCD. It can be seamlessly combined with different anomaly detection methods and classify unseen\nanomalies detected into homogeneous groups.\n• We study the challenges of learning from anomalous regions in industrial scenarios, motivating us to propose\nMEBin and mask-guided representation learning for our\nnetwork to focus on real anomalous regions and learn discriminative features of isolated anomalies.\n• AnomalyNCD surpasses existing anomaly clustering\nmethods and NCD methods on the MVTec AD and MTD\ndatasets, providing a decent foundation for downstream\nanomaly treatments in industrial scenarios.\n\n2.2. Novel Class Discovery\nNovel Class Discovery setting was first formalized in [18].\nThe early methods follow a two-stage pipeline [18, 20, 21].\nThe first stage is to learn representation from the base set to\nobtain prior knowledge for classification, which serves as\nthe basis for the second one to train the model on the novel\nset. Recent methods are one-stage [19, 46, 56]. By handling\nthe base set and novel set simultaneously, one-stage methods extract better representations with less bias towards the\nbase classes. NCD has been applied in several fields, such\nas medical image classification [14, 58], semantic segmentation [55] and point cloud segmentation [37, 49]. In this\npaper, we introduce the NCD architecture into multi-class\nindustrial anomaly classification for the first time.\n\n2.3. Binarization Approach\nBinarization is a crucial preprocessing step for various\nvision tasks, e.g., edge detection [6, 59], segmentation\n[10, 16, 57], document image processing [7, 34, 41], medical image processing [39, 42], object detection [50–52],\netc. Otsu [35] determines the optimal threshold to separate the foreground and background by maximizing the\nbetween-class variance of the pixel intensities. DiffuMask\n[48] utilizes cross-attention maps and adaptive thresholding\nto generate binary maps. However, these methods usually\nobtain fragmented false-positive regions when segmenting\nthe anomalies, which harms the region-level anomaly class\nprediction. To alleviate this, we propose the main element\n\n2. Related Work\n2.1. Image Clustering in Industrial Scenarios\nDirectly clustering the images cannot perform well in multiclass anomaly classification. To address this issue, two\nstudies build the clustering pipeline specific for fine-grained\nanomaly classes. Sohn et al. [40] proposed a simple but effective method to aggregate the patch features by anomaly\nmap weighting. Lee et al. [28] only aggregates the patch\n2\n\n\fcrop\n\nanomaly score\n\nUnlabeled\n\nMask-Guided Representation Learning\n\nPseudo\nlabel\n\nPredicted mask mask vector\n\nAD\n\nSA\n\nMEBin\n\n…\n\nPrediction\nMGA … MGA … MGA\n\nSA\n\nclassifier\nTrue\nlabel\n\nSub-image\nLabeled\n\ncrop\n\nPLC\n\nAttention maps :\n\nPrediction\n\nGT\nUnlabeled (novel) Class Branch\n\nMEBin\n\nMain Element Binarization\n\nSA\n\nSelf-Attention\n\nLabeled (base) Class Branch\n\nPLC\n\nPseudo Labels Correction\n\nMGA\n\nMask-Guided Attention\n\nAnomaly Detection Method\n\nAD\n\nCross-Entropy Loss\n\nFigure 2. Illustration of the Training Process for AnomalyNCD. First, we apply main element binarization (MEBin) to segment anomaly\nmasks from detection results and generate anomaly-centered sub-images. Second, we introduce mask-guided representation learning to\nlearn discriminative features of anomalies, classifying sub-images into various categories.\nSetting threshold\nsearch range\n\n1\n\nBinarization using\nall thresholds\n\nsegmented regions 𝛿𝛿𝑗𝑗\n\nAnomaly\ndetection\n\nbinarization strategy to extract only the primary anomaly region, thereby reducing the impact of false positives on representation learning.\n\n2\n\nFinding main\nanomaly regions\n\n3\n\n10\n\n3. Method\n\n3D visualization\n\n8\n6\n4\n\nThe proposed AnomalyNCD aims to automatically discover\nand recognize the visual categories of industrial anomalies.\nFig. 2 illustrates its overall framework. To extract main\nanomaly regions from detection results, we outline the main\nelement binarization method (Sec. 3.2). Guided by these\nanomaly regions, we then apply mask-guided representation learning (Sec. 3.3) to extract and classify discriminative\nfeatures of anomalies within these regions. Finally, a region\nmerging strategy (Sec. 3.4) ensures robust image-level classification based on all anomaly regions.\n\nlongest range\n\n2\n0\n\n0\n\n10\n\n20\n\n30\n\n40\n\nThreshold index 𝑗𝑗\n\n50\n\n60\n\nFigure 3. Pipeline of the Main Element Binarization. In 3D\nvisualization, we show the changes of segmented regions under\ndifferent thresholds. The 3D map (a) corresponds to the 2D binary\nsegmentation mask (a).\n\n[0, 1]H×W . However, Ai inevitably contains false positives\n(over-detections) and false negatives (missed detections).\nThese errors can negatively affect multi-class anomaly classification. To address this, we propose a Main Element\nBinarization (MEBin) approach. It extracts the principal\nanomaly structures (Main Element) from Ai by focusing\non stable regions across small threshold variations. Overall, the MEBin consists of three steps: ❶ Predefine a range\n[smin , smax ] for threshold exploration; ❷ Binarize Ai across\nall thresholds within this range; ❸ Identify the main elements in Ai based on the changes of segmented regions under different binarization results.\nThe first step: To capture all potential anomalies across\nthe set {Ai |i ∈ [1, N u ]}, the upper limit smax is set to 1.\nConversely, the lower limit, smin , is determined by the minimum anomaly score1 found across the set {Ai |i∈[1, N u ]},\nrepresented as smin = min(s1 , s2 , ..., sN u ), where si =\nmax(Ai ). Such a lower limit helps minimize the likelihood\nof normal image pixels being segmented.\nThe second step: To analyze the segmented regions\n\n3.1. Problem Definition\nGiven a set of unlabelled images Du = {Iiu |i ∈ [1, N u ]},\nthe goal of AnomalyNCD is to assign them into C u classes\n(named “Novel” previously), where C u is known as a priori,\nreferring to vanilla NCD [15, 17, 45]. To provide a better\nfoundation for learning novel classes, we follow previous\nNCD tasks to assume a set of labeled anomaly images Dl =\n{(Iil , yil , Mli )|i ∈ [1, N l ]} with C l classes available (named\nl\nu\n“Base” previously), where yil ∈ R1×(C +C ) is the one-hot\nl\nclass label, and Mi is the ground truth anomaly mask of\nimage Iil ∈ Dl . Dl supplies the auxiliary knowledge of\nthe industrial anomalies for grouping the images in Du . To\nfurther generalize our study, we also perform experiments\nwith different Dl and without Dl in the Appendix F.\n\n3.2. Main Element Binarization\nTo provide a clear anomaly indication of unlabeled images, we use an anomaly detection method on Iiu to\ngenerate the anomaly probability map, denoted as Ai ∈\n\n1 Anomaly score: Maximum value in an anomaly probability map.\n\n3\n\n\fchange with thresholds, we uniformly sample T thresholds {ϵj |j ∈ [1, T ]} in [smin , smax ]. For each threshold ϵj , the anomaly map Ai is binarized into a mask Mij :\nMij = 1[Ai &gt; ϵj ], where 1[.] is the indicator function. To\nreduce the meaningless and fragmented segmentation, we\nfurther apply an erosion operation to each mask Mij .\nThe third step: We identify main anomaly regions\nthrough two operations. First, let δij denote the number\nof individual regions segmented in Mij , each region is an\nindependent connected component. We observe that the\namount of the main regions in the anomaly map Ai can be\ncharacterized by the non-zero value that appears most frequently in {δij |j∈[1, T ]}, denoted as δ̄i . Second, to segment\nthe main regions, we take the longest continuous threshold range where only δ̄i regions are segmented. The main\nanomaly regions remain stable within this threshold range,\nas shown in Fig. 3.\n\nImage\n\nGT\nmask\n\nPredicted\nmask\n\nDINO\nattention\n\nMG\nattention\n\nFigure 4. Visualization of the self-attention of the [CLS] token\non the last layer’s heads. DINO attention refers to the [CLS]\ntoken extracted from a DINO pre-trained ViT that mainly focuses\non a foreground object. AnomalyNCD uses a mask to direct the\n[CLS] token’s attention to the anomalous regions.\n\n• If this range is shorter than τ , there is no anomaly region\nto be segmented.\n• Conversely, if this range exceeds τ , it confirms stable\nanomaly segmentation within this threshold range. In this\ncase, we select the minimum threshold from the identified\nrange to segment anomalies as completely as possible.\n\n“token” and is flattened into an embedding vector of length\nD. ViT has L sequential transformer layers, each containing self-attention layers and feed-forward neural networks.\nIn addition, a special class token [CLS], is propagated\nfrom the first layer to the final layer where it serves as the\nbasis for classification. In the self-attention of the lth layer,\nthe input patches undergo linear projections to form the\nqueries, keys, and values Ql−1 , Kl−1 ,Vl−1 ∈ R(N+1)×D .\nHere, ViT captures the relationships between the image\npatches by self-attention mechanism Attn as follows:\n\u0001\npatch ⊤\n⊤\nAttn = softmax concat(Qcls\nl−1 Kl−1 , Ql−1 Kl−1 ) Vl−1\n(1)\npatch\n1×D\nN×D\nwhere we divide Ql−1 into Qcls\n∈R\nand\nQ\n∈R\nl−1\nl−1\nto represent class token and patch tokens separately.\nInsufficient Focus on Anomalies. The ViT excels in semantic representation but fails to detect weak semantic\nanomalies. Fig. 4 demonstrates this using the self-attention\nmap of the [CLS] token in the last layer of a DINOpretrained ViT [9]. In the 1st row’s example, the model\nhighlights the salient object (metal grid) in an image, rather\nthan the local anomaly. This observation means that the\nnetwork over-focuses on learning background.\nMask-Guided Attention. To address the issue above, we\npropose mask-guided attention to direct ViT’s focus on the\nanomalous region. Specifically, the input sub-image xi,k is\nfed into the ViT, and we assume the token √\nnumber\n√ is N. At\nthe same time, its mask mi,k is resized to N× N by average pooling and then flattened into a vector M ∈ RN×1 .\nSubsequently, we insert the constant 1 at the beginning of\nM to align its size with the tokens. Next, we use the mask\nvector in the self-attention mechanism for re-directing focus, which has three possible design choices.\n1. Adding the mask M on both class and patch tokens.\n2. Adding the mask M on the patch tokens.\n\nFinally, we use the selected threshold to segment Ai into\nthe binary mask, denoted as Mu\ni . In this way, the unlabeled images set Du are extended with the binary masks:\nu\n{(Iiu , Mu\ni )|i ∈ [1, N ]}.\nAnomaly-Centered Sub-Image Cropping. To focus the\nmodel on anomalous regions, we crop each region in Mu\ni\nindividually into anomaly-centered sub-images. Specifically, for each region in Mu\ni , we use the minimum bounding square to crop the sub-image from Iiu and its mask\nu\nfrom Mu\ni . Then the sub-images of Ii can be denoted as\nu\nu\n{xi,1 , xi,2 , . . .}, and the corresponding masks cropped from\nu\nu\nMu\ni are denoted as {mi,1 , mi,2 , . . .}. To align labeled and\nunlabeled inputs, we use the same cropping operation to extract sub-images and masks for the labeled data set Dl , denoted as {(xli,1 , mli,1 ), (xli,2 , mli,2 ), . . . |i ∈ [1, N l ]}. These\nare then merged with the unlabeled data in the same structures, represented as {(xi,k , mi,k , yi,k )|i ∈ [1, N l +N u ], k ∈\n[1, δ̄i ]}, where δ̄i indicates the number of sub-images per\nimage, and yi,k is the one-hot class label for each labeled\nsub-image, matching the label of the ith image if it belongs\nto Dl . Implementation details of the cropping process are\nsupplied in the Appendix C.\n\n3.3. Mask-Guided Representation Learning\n3.3.1. Mask-Guided Vision Transformer (MGViT)\nMGViT is built on vision transformer (ViT). Thus we review its structure.\nVision transformer [13] processes an input image by dividing it into N fixed-size patches. Each patch is treated as a\n4\n\n\fUnlabeled Image Predicted Mask\n\n3. Adding the mask M on the class token.\nThe 1st and 2nd designs suppress the rich contextual features in patch tokens that are crucial for classification, and\nour network only focuses on classifying anomalies rather\nthan segmenting. Thus, the 3rd one is recommended as the\nmost suitable design, and the experiment also verifies its effectiveness. Such a design can be formulated as follows:\n\n: prediction of\ncropped image\n: one-hot label of\nunlabeled image\n: prediction of\nunlabeled image\n\nTrue label\nReal\n\npatch ⊤\n⊤\nAttn = softmax(concat(Qcls\nl−1 Kl−1 +M , Ql−1 Kl−1))Vl−1\n(2)\nwhere M denotes the converted mask vector that is compatible with the attention mechanism [12]:\n(\n0,\nif M(i) &gt; 0.5\n(3)\nM(i) =\n−∞,\notherwise\n\nClass-2\n\nSub-image-1\nFake\n\nPrediction-1\n\nSub-image-2\n\nPrediction-2\n\n(a)\nArea-weighted prediction\n\nClass-3\n(b)\n\nAverage prediction\n\nFigure 5. Region merging strategy for image-level classification. Using average prediction, the output of normal cropped images (Sub-image-2) leads to final misclassification, while areaweighted prediction can reduce the negative effect of normal\ncropped images on the final result.\n\nNote that, in the ViT, the self-attention in the last Lm -layer\nis replaced with the mask-guided attention to form MGViT.\nFig. 4 reveals that the [CLS] token focuses on anomalous\nregions by using our mask-guided attention. Even though\nthe predicted masks do not align with the ground truth accurately, the network still focuses on the anomaly roughly.\n\nThe overall loss of training objective is written as:\nu\nL = λ(Llrep + Llcls ) + (1 − λ)(Lrep + Lu\ncls + µLreg ) (4)\n\nwhere λ is a hyperparameter that balances the supervised\nloss and the self-supervised loss. µ is the coefficient of the\nregularization.\nPseudo Labels Correction. The error in pseudo labels\nleads to the false learning objective for the classification\nmodel. To mitigate these errors, especially the false detection of anomalous regions, we propose to use anomaly\nscores (described in Sec 3.2) to correct pseudo labels.\nLet si,k denote the anomaly score for xi,k , we weightedly judge whether the view x̂i,k should be labeled as normal or assigned the generated pseudo labels.\n\n3.3.2. Model Training\nGiven a sub-image pair (xi,k , mi,k ), we first apply random augmentation to generate two views (x̃i,k , m̃i,k ) and\n(x̂i,k , m̂i,k ). Following DINO [9], we feed these two views\ninto the teacher and student networks respectively, which\nhave shared MGViT and classification heads with different\nsoftmax temperatures. For labeled sub-images, the ground\ntruth labels are converted into one-hot vectors to serve as\nsupervision targets for the student network. For unlabeled\nsub-images x̃i,k , x̂i,k , we generate pseudo labels q̂i,k , q̃i,k ∈\nl\nu\nR1×(C +C ) by the “teacher” one, which employs a sharp\ntemperature τt to produce confident predictions. The entries of labeled classes (C l ) in the pseudo labels are set to 0.\nThe “student” one, using a smooth temperature τs , is trained\nl\nu\nto align its probability predictions p̂i,k , p̃i,k ∈ R1×(C +C )\nwith either ground truth labels (for labeled data) or pseudo\nlabels (for unlabeled data). This dual supervision ensures\neffective learning from both labeled and unlabeled data.\nOur training objective follows existing category discovery methods [45, 47] and includes classification objective\nand representation learning objective. The classification objective contains ground truth label supervision Llcls on labeled sub-images, and pseudo label supervision Lu\ncls on unlabeled sub-images. The representation learning objective\ncontains self-supervised contrastive learning Lrep [11] on\nboth labeled sub-images and unlabeled sub-images, and supervised contrastive learning Llrep [26] on only labeled subimages. Finally, we adopt a mean-entropy maximization\nregularizer Lu\nreg [8] for unlabeled sub-images. More details\nabout the training procedure are provided in Appendix A.\n\nq̂i,k ← wi,k e+(1−wi,k )q̂i,k ; wi,k = max(0.5−si,k , 0) (5)\nl\n\nu\n\nwhere wi,k is the weight for normal. e ∈ R1×(C +C ) denotes a unit vector whose (C l + 1)-th value is 1 and all other\nvalues are 0, in which we use the first class in the C u classes\nas normal. If si,k is smaller, the more likely the sub-image\nx̂i,k is normal, and q̂i,k is closer to e. Thus, such correction\nforces the network to separate normal sub-images from the\ntrain set. In the same way, the pseudo label q̃i,k is updated.\n\n3.4. Region Merging for Image Classification\nFor flexible classification in both sub-image and image levels, we aim to determine the image’s anomaly class according to its sub-image classification. Intuitively, a naive\nmethod is to average the predictions of all sub-images\nwithin an image. However, false classification of the overdetected region may mislead the image class. As shown\nin Fig. 5, Sub-image-1 and Sub-image-2 are classified to\nClass-2 and Class-3, respectively, where the wrong prediction of Sub-image-2 misleads the image class in Fig. 5 (b).\n5\n\n\fDatasets\n\nMVTec AD [5]\n\nMTD [23]\n\nMetric IIC[25] GATCluster[33] SCAN[44] UNO[15] GCD[45] SimGCD[47] AMEND[3]\n\nAC[40]\nMuSc [30]\n(Unsup.) +AnomalyNCD\n\nNMI\nARI\nF1\n\n0.093\n0.020\n0.285\n\n0.136\n0.053\n0.264\n\n0.210\n0.103\n0.335\n\n0.146\n0.052\n0.342\n\n0.417\n0.302\n0.553\n\n0.452\n0.346\n0.569\n\n0.431\n0.333\n0.542\n\n0.525\n0.431\n0.604\n\n0.613\n0.526\n0.712\n\nNMI\nARI\nF1\n\n0.064\n0.020\n0.252\n\n0.028\n0.009\n0.243\n\n0.041\n0.029\n0.282\n\n0.034\n0.011\n0.221\n\n0.211\n0.115\n0.381\n\n0.105\n0.048\n0.293\n\n0.138\n0.067\n0.324\n\n0.179\n0.120\n0.346\n\n0.268\n0.228\n0.509\n\nTable 1. Quantitative results on the MVTec AD and MTD dataset. All the methods only use unlabeled images as input. The best-performing\nresult is in bold, the second best result is underlined.\n\nDatasets\n\nAC[40]\nUniFormaly[28]\nMetric (Semi-sup.) (0.953 / 0.837)\n\nPatchCore[38]\nRD++[43]\nEfficientAD[4]\nPNI[2]\nCPR[29]\n(0.938 / 0.729) (0.950 / 0.741) (0.917 / 0.731) (0.942 / 0.516)\n(0.964 / -)\n+AnomalyNCD +AnomalyNCD +AnomalyNCD +AnomalyNCD +AnomalyNCD\n\nMVTec AD [5]\n\nNMI\nARI\nF1\n\n0.608\n0.489\n0.652\n\n0.547\n0.433\n0.645\n\n0.670\n0.601\n0.769\n\n0.631\n0.542\n0.721\n\n0.516\n0.394\n0.641\n\n0.675\n0.609\n0.769\n\n0.736\n0.674\n0.805\n\nMTD [23]\n\nNMI\nARI\nF1\n\n0.390\n0.314\n0.490\n\n0.421\n0.322\n0.609\n\n0.380\n0.390\n0.617\n\n0.368\n0.361\n0.600\n\n0.220\n0.188\n0.467\n\n0.181\n0.219\n0.465\n\n-\n\nTable 2. Quantitative results on the MVTec AD and MTD dataset. All the methods use unlabeled images and labeled normal images as\ninput. We evaluate the AUPRO metric across various anomaly detection approaches on two datasets, e.g., (0.953 / 0.837), the first one\non the MVTec AD dataset and the second on the MTD dataset. For the metrics of multi-class anomaly classification, the best-performing\nresult is in bold, the second best result is underlined. The unofficial results are marked in gray .\n\nTo address this issue, we propose a region merging approach to robustly classify images. We found that misclassification is mostly over-detected regions that are much\nsmaller than real anomalies. Therefore, we define an areau\nrelated weight αi,k\nfor each sub-image xu\ni,k , which is used\nin determining the image category:\np\nexp( au\ni,k /τα )\nu\nαi,k = Pδ̄\n(6)\np u\ni\nk=1 exp( ai,k /τα )\n\nclass, as described in the Appendix G. MTD dataset has\n952 normal images and 392 abnormal images, the abnormal images are divided into five anomaly classes. We follow [40] that uses 80% of normal images as the reference\nimages and the rest as the test images. For both datasets,\nwe use the single-blade sub-dataset in Aero-engine Blade\nAnomaly Detection Dataset (AeBAD-S) [54] with the normal class removed, as our default labeled image set Dl .\n4.1.2. Implementation details\n\nu\nwhere au\ni,k is the area of anomaly in xi,k , and τα is the\ntemperature value. Then, for an image Iiu composed by\nu\nsub-images {xu\ni,k |k ∈ [1, δ̄i ]}, the prediction logit is pi =\nPδ̄i\nu u\nu\nk=1 αi,k pi,k , where pi,k is the probability prediction of\nu\nxi,k generated by the student network. As shown in Fig. 5\nu\n(a), the prediction pu\ni depends more on pi,1 , which has a\nu\nlarger weight αi,1 and a correct prediction.\n\nWe use ViT-B/8 [13] pre-trained with DINO [9] as our feature extractor. The self-attentions in the last 9 layers are\nreplaced with our mask-guided attention. During training,\nall the layers of ViT are fixed except the last layer. For\nanomaly detection methods preceding AnomalyNCD, we\nchoose zero-shot method MuSc [30], one-class methods\nPatchCore [38], EfficientAD [4], RD++ [43], PNI [2] and\nCPR [29]. More details are in the Appendix B.\n\n4. Experiments\n\n4.1.3. Competing methods\n\n4.1. Experimental setting\n\nWe compare our method with two state-of-the-art industrial anomaly clustering methods, UniFormaly [28] and\nAnomaly Clustering [40] that has two settings: an unsupervised one (Unsup.) and a semi-supervised one (Semisup.). The former setting only inputs unlabeled images\nfor clustering, while the latter one uses labeled normal images, same as the input of one-class anomaly detection. We\nalso employ three deep clustering methods, IIC [25], GATCluster [33], and SCAN [44], which cluster unlabeled im-\n\n4.1.1. Datasets\nWe conduct experiments on industrial datasets MVTec AD\n[5] and Magnetic Tile Defect (MTD) [23]. MVTec AD\nhas industrial product images of 10 object categories and\n5 texture categories. Each product category has at least\ntwo anomaly classes. Following [40] and [28], we remove\nthe combined anomaly classes for a fair comparison. Notice that our method can also handle the combined anomaly\n6\n\n\fAvg FPR ↓\n\nAvg FNR ↓\n\nNMI ↑\n\nARI ↑\n\nF1 ↑\n\n0.572\n0.678\n0.484\n0.269\n0.544\n0.676\n0.153\n\n0.617\n0.742\n0.165\n0.247\n0.593\n0.525\n0.035\n\n0.554\n0.499\n0.567\n0.495\n0.077\n0.382\n0.613\n\n0.482\n0.404\n0.458\n0.395\n0.013\n0.268\n0.526\n\n0.650\n0.587\n0.640\n0.623\n0.337\n0.499\n0.712\n\nMetrics\n\nϵ = 0.1\nϵ = 0.3\nϵ = 0.5\nϵ = 0.7\nϵ = 0.9\nOtsu [35]\nOurs\n\nThreshold\n(a) CPR\n\nTable 3. Ablation study of different binarization approaches on the\nMVTec AD dataset. The best-performing result is in bold.\n\nThreshold\n(b) PNI\n\nFigure 6. The results of various anomaly detection (AD) methods under multiple fixed thresholds. The horizontal dashed line\nrepresents the results of MEBin. Notably, the optimal fixed thresholds differ across AD methods, while our MEBin consistently outperforms the fixed threshold results.\n\nages directly. In addition, four NCD methods in the nature scene are considered for comparison, UNO [15], GCD\n[45], SimGCD [47] and AMEND [3]. As in our method,\nthe AeBAD-S dataset is used as labeled abnormal images.\n\nw/o MG\n\n4.1.4. Evaluation metrics\n\nw/ MG\n\nWe report three widely used metrics for the evaluation of\nclustering: the F1 score, the normalized mutual information (NMI) [32], and the adjusted rand index (ARI) [36].\nWe use the Hungarian algorithm [27] to match the predicted clusters to the ground truth labels. For methods using anomaly maps, we measure the segmentation per-region\noverlap (AUPRO) with 30% FPR [5] to explore the impact\nof anomaly detection performance on the multi-class classification. All metrics are calculated by the official code.\n\n4.2. Quantitative results\n\nmetal nut\n\nWe report the results of the multi-class anomaly classification on the MVTec AD and MTD datasets in Table 1\nand 2. Notably, AnomalyNCD is compatible with all the\nanomaly detection methods to enable subsequent multiclass anomaly classification.\nAll methods in Table 1 only use unlabeled images as input. Compared to Anomaly Clustering [40], AnomalyNCD\ncombined with zero-shot anomaly detection method MuSc\n[30], achieves 8.8% gains on NMI, 9.5% gains on ARI, and\n10.8% F1 gains, proving that AnomalyNCD extracts more\ndiscriminative features than Anomaly Clustering through\ncontrastive learning in anomalous regions. AnomalyNCD\nalso outperforms state-of-the-art NCD methods, achieving\n16.1% gains on NMI, 18.0% gains on ARI, and 14.3% F1\ngains. The performance advantage of AnomalyNCD is due\nto focusing on anomalies inside images.\nIn Table 2, all methods utilize both unlabeled images and\nlabeled normal images from the same product. We integrate\nAnomalyNCD with various one-class AD methods. Utilizing CPR, which has the highest AUPRO, achieves the best\nperformance on the MVTec AD dataset: NMI increases by\n10.7%, ARI by 14.9%, and F1 score by 9.6%, surpassing\nother methods. On the MTD dataset, although the segmentation AUPRO of all AD methods is lower than that of Uniformaly, PatchCore+AnomalyNCD still achieves improvements of 6.8% in ARI and 0.8% in F1 score.\n\nhazelnut\n\nwood\n\nFigure 7. T-SNE visualization of sub-images on the MVTec AD\ndataset. We choose metal nut, hazelnut and wood as examples.\nThe different colors of dots represent their anomaly classes.\n\n4.3. Ablation Study\n4.3.1. Effectiveness of main element binarization\nTable 3 compares MEBin’s performance with the Otsu\nmethod [35] and fixed thresholds. Since the missed detection is more critical than over-detection in industrial scenarios, we define an anomaly as detected if the intersection\nover union (IoU) between the actual and predicted bounding boxes exceeds 0.1. Then we calculate the FPR and FNR\nfor these binarization methods. MEBin demonstrates lower\nFPR and FNR than fixed thresholds and Otsu, leading to\nbetter multi-class classification results. Compared to the\nfixed thresholds, MEBin adaptively determines an optimal\nthreshold for each image adaptation and achieves a 7.2% F1\nimprovement. The Otsu tends to over-detect, particularly in\nnormal images, making it less effective for this task.\nIn Fig. 6, we further apply MEBin on different one-class\nAD methods, which exhibit varying optimal fixed thresholds. For example, the optimal threshold of CPR [29] is near\n0.5, whereas for PNI [2] it is approximately 0.3. MEBin’s\nadaptive threshold selection for each image outperforms all\nfixed thresholds for the whole image set.\n7\n\n\fMask Mechanism\n\nNMI\n\nARI\n\nF1\n\n(a) w/o MGA\n(b) all tokens\n(c) patch tokens\n(d) class token (Ours)\n\n0.598\n0.507\n0.563\n0.613\n\n0.494\n0.382\n0.467\n0.526\n\n0.698\n0.600\n0.686\n0.712\n\nMVTec AD\n\nTable 4. Compared with different mask attention mechanisms on\nthe MVTec AD dataset, the best-performing result is in bold.\nMVTec AD\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\n(i) Avg\n(ii) Score Avg\n(iii) Area Avg\n\n0.610\n0.600\n0.613\n\n0.521\n0.513\n0.526\n\n0.709\n0.703\n0.712\n\n0.257\n0.228\n0.268\n\n0.223\n0.208\n0.228\n\n0.501\n0.485\n0.509\n\nTable 6. Compared with different merging strategies on the\nMVTec AD and MTD datasets.\n\nMTD\n\nLm\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\n1\n3\n6\n9\n12\n\n0.606\n0.608\n0.613\n0.613\n0.609\n\n0.508\n0.511\n0.519\n0.526\n0.521\n\n0.690\n0.694\n0.713\n0.712\n0.712\n\n0.191\n0.209\n0.253\n0.268\n0.249\n\n0.157\n0.173\n0.214\n0.228\n0.213\n\n0.420\n0.436\n0.492\n0.509\n0.492\n\nMTD\n\nMerge\n\nw/o PLC\nw PLC\n\nPrecision\n\nRecall\n\nNMI\n\nARI\n\nF1\n\n0.797\n0.821\n\n0.727\n0.876\n\n0.597\n0.613\n\n0.517\n0.526\n\n0.714\n0.712\n\nTable 7. The ablation experiment of pseudo label correction (PLC)\non the MVTec AD dataset. We evaluate the precision and recall of\nthe normal class.\n\nTable 5. Ablation study on the position of mask-guided layers on\nMVTec AD and MTD datasets. Best results in bold.\n\ndatasets. In anomaly detection, noise inevitably leads to\nover-detections, which have small areas but large anomaly\nscores. Directly averaging results over all sub-images is inaccurate, especially when many false positive sub-images\nare involved. Similarly, using anomaly scores as weights is\nalso inappropriate. In contrast, our merging method, which\nassigns weights to multiple sub-image predictions based on\narea, achieves more robust merged predictions.\n\n4.3.2. Discussion of the mask-guided attention\nThe mask-guided attention (MGA) directs ViT to focus on\ntokens within the mask (anomalous region). We show the\nt-SNE visualization in Fig. 7. With MGA in the 2nd row,\nimage features have larger inter-class distances (e.g. metal\nnut) and smaller intra-class distances (e.g. hazelnut and\nwood) than those without MGA in the 1st row. In terms\nof metrics on MVTec AD, our MGA has a 1.5% NMI gain,\n3.2% ARI gain, and 1.4% F1 gain shown in Table 4.\nWe conduct experiments to introduce the binary mask\ninto different tokens in Table 4. (b) introduces the binary mask on [CLS] token and patch tokens. (c) introduces it on patch tokens. Our MGA (d) only performs on\n[CLS] token, which is directly input into the classifier. We\nmake patch tokens have a global receptive field to introduce\nmore surrounding information indirectly into [CLS] token. Compared to other mask strategies, our MGA achieves\n5.0% NMI, 5.9% ARI, and 2.6% F1 improvements.\n\n4.3.5. Effect of Pseudo Label Correcting\nOur Pseudo Label Correcting (PLC) aims to reduce the impact of over-detections from the anomaly detection process.\nAlthough over-detected sub-images are normal, they have\nlarge appearance differences, which makes it difficult to\ncorrectly group them into the same normal class. Table 7\npresents the precision and recall of the normal class. After\napplying PLC, recall improves by 14.9%, which means that\nsome misclassified normal sub-images are corrected by our\nPLC. Additionally, a 1.6% improvement in NMI is observed\nin the multi-class classification results.\n\n4.3.3. The influence of the mask-guided layer Lm\n\n5. Conclusion\n\nIn our method, we introduce mask-guided attention in the\nlast Lm layers of ViT. As reported in Table 5, we conduct\nthe experiments with different Lm . The results demonstrate\nthat using mask-guided attention in the last 9 layers yields\nbetter performance on both datasets. When Lm is small,\nthe [CLS] token cannot adequately focus on the anomaly\nwithin the binary mask. In contrast, when Lm = 12,\nthe [CLS] token completely lost contextual information\naround the anomaly, resulting in a drop in metrics.\n\nIn this paper, we propose a novel multi-class anomaly classification method AnomalyNCD, which is compatible with\nexisting anomaly detection methods. Firstly, we propose the\nmain element binarization approach to isolate most overdetections and missed detections brought by anomaly detection methods. Secondly, we crop each anomalous region and leverage mask-guided representation learning to\nfocus the network on the local anomaly and learn discriminative representations. Finally, our region merging strategy achieves flexible classification at sub-image and image\nlevels during inference. While the performance of AnomalyNCD is generally influenced by the quality of the anomaly\ndetection method, our AnomalyNCD outperforms all the\ncurrent industrial anomaly clustering methods and NCD\nmethods in the nature scene.\n\n4.3.4. Discussion of merging strategies\nIn Table 6, we report results using different merging strategies. (i) averaging the predictions of the sub-images, (ii)\nutilizing the anomaly scores of the sub-images as weights\nto merge, and (iii) using our region merging strategy. Strategy (iii) achieves better metrics than (i) and (ii) on both\n8\n\n\f6. Acknowledgments\n\n[12] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Masked-attention mask\ntransformer for universal image segmentation. In IEEE/CVF\nConference on Computer Vision and Pattern Recognition\n(CVPR), 2022. 5\n[13] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov,\nDirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner,\nMostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021. 4, 6\n[14] Jianan Fan, Dongnan Liu, Hang Chang, Heng Huang, Mei\nChen, and Weidong Cai. Seeing unseen: Discover novel\nbiomedical concepts via geometry-constrained probabilistic\nmodeling. IEEE/CVF Conference on Computer Vision and\nPattern Recognition (CVPR), 2024. 2\n[15] Enrico Fini, Enver Sangineto, Stéphane Lathuiliere, Zhun\nZhong, Moin Nabi, and Elisa Ricci. A unified objective for\nnovel class discovery. In IEEE/CVF International Conference on Computer Vision (ICCV), 2021. 3, 6, 7\n[16] Shi Gong, Huan Zhou, Feng Xue, Cong Fang, Yiqun Li, and\nYu Zhou. Fastroadseg: Fast monocular road segmentation\nnetwork. IEEE Transactions on Intelligent Transportation\nSystems (TITS), 23(11):21505–21514, 2022. 2\n[17] Peiyan Gu, Chuyu Zhang, Ruijie Xu, and Xuming He. Classrelation knowledge distillation for novel class discovery. In\nIEEE/CVF International Conference on Computer Vision\n(ICCV), 2023. 3\n[18] Kai Han, Andrea Vedaldi, and Andrew Zisserman. Learning\nto discover novel visual categories via deep transfer clustering. In IEEE/CVF International Conference on Computer\nVision (ICCV), 2019. 2\n[19] Kai Han, Sylvestre-Alvise Rebuffi, Sebastien Ehrhardt, Andrea Vedaldi, and Andrew Zisserman. Autonovel: Automatically discovering and learning novel visual categories. IEEE\nTransactions on Pattern Analysis and Machine Intelligence\n(TPAMI), 44(10):6767–6781, 2021. 2\n[20] Yen-Chang Hsu, Zhaoyang Lv, and Zsolt Kira. Learning to\ncluster in order to transfer across domains and tasks. In International Conference on Learning Representations (ICLR),\n2018. 2\n[21] Yen-Chang Hsu, Zhaoyang Lv, Joel Schlosser, Phillip Odom,\nand Zsolt Kira. Multi-class classification without multi-class\nlabels. In International Conference on Learning Representations (ICLR), 2019. 2\n[22] Bozhen Hu, Bin Gao, Wai Lok Woo, Lingfeng Ruan, Jikun\nJin, Yang Yang, and Yongjie Yu. A lightweight spatial and\ntemporal multi-feature fusion network for defect detection.\nIEEE Transactions on Image Processing (TIP), 30:472–486,\n2021. 1\n[23] Yibin Huang, Congying Qiu, and Kui Yuan. Surface defect\nsaliency of magnetic tile. The Visual Computer, 36(1):85–\n96, 2020. 2, 6\n[24] Jongheon Jeong, Yang Zou, Taewan Kim, Dongqing Zhang,\nAvinash Ravichandran, and Onkar Dabeer. Winclip: Zero/few-shot anomaly classification and segmentation. In\nIEEE/CVF Conference on Computer Vision and Pattern\nRecognition (CVPR), 2023. 1\n\nThis work was supported by the National Natural Science\nFoundation of China under Grant No.62176098. The computation is completed in the HPC Platform of Huazhong\nUniversity of Science and Technology.\n\nReferences\n[1] Andrei-Timotei Ardelean and Tim Weyrich. Blind localization and clustering of anomalies in textures. IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshop (CVPR Workshop), 2024. 1\n[2] Jaehyeok Bae, Jae-Han Lee, and Seyun Kim. Pni: industrial anomaly detection using position and neighborhood information. In IEEE/CVF International Conference on Computer Vision (ICCV), 2023. 6, 7\n[3] Anwesha Banerjee, Liyana Sahir Kallooriyakath, and Soma\nBiswas. Amend: Adaptive margin and expanded neighborhood for efficient generalized category discovery. In\nIEEE/CVF Winter Conference on Applications of Computer\nVision (WACV), 2024. 6, 7\n[4] Kilian Batzner, Lars Heckler, and Rebecca König. Efficientad: Accurate visual anomaly detection at millisecond-level\nlatencies. In IEEE/CVF Winter Conference on Applications\nof Computer Vision (WACV), 2024. 6\n[5] Paul Bergmann, Michael Fauser, David Sattlegger, and\nCarsten Steger. Mvtec ad–a comprehensive real-world\ndataset for unsupervised anomaly detection. In IEEE/CVF\nConference on Computer Vision and Pattern Recognition\n(CVPR), 2019. 2, 6, 7\n[6] Gedas Bertasius, Jianbo Shi, and Lorenzo Torresani.\nDeepedge: A multi-scale bifurcated deep network for topdown contour detection. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2015. 2\n[7] Showmik Bhowmik, Ram Sarkar, Bishwadeep Das, and\nDavid Doermann. GiB: A Game Theory Inspired Binarization Technique for Degraded Document Images. IEEE\nTransactions on Image Processing (TIP), 28(3):1443–1455,\n2019. 2\n[8] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning\nof visual features by contrasting cluster assignments. Advances in Neural Information Processing Systems (NeurIPS),\n2020. 5\n[9] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou,\nJulien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In\nIEEE/CVF International Conference on Computer Vision\n(ICCV), 2021. 4, 5, 6\n[10] Yicong Chang, Feng Xue, Fei Sheng, Wenteng Liang, and\nAnlong Ming. Fast road segmentation via uncertainty-aware\nsymmetric network. In IEEE International Conference on\nRobotics and Automation (ICRA), 2022. 2\n[11] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International Conference on\nMachine Learning (ICML), 2020. 5\n\n9\n\n\fof brain image. Signal &amp; Image Processing, 3(6):35, 2012.\n2\n[40] Kihyuk Sohn, Jinsung Yoon, Chun-Liang Li, Chen-Yu Lee,\nand Tomas Pfister. Anomaly clustering: Grouping images\ninto coherent clusters of anomaly types. In IEEE/CVF Winter Conference on Applications of Computer Vision (WACV),\n2023. 1, 2, 6, 7\n[41] Bolan Su, Shijian Lu, and Chew Lim Tan. Robust document\nimage binarization technique for degraded document images.\nIEEE Transactions on Image Processing (TIP), 22(4):1408–\n1417, 2012. 2\n[42] Torbjørn Sund and Karsten Eilertsen. An algorithm for fast\nadaptive image binarization with applications in radiotherapy imaging. IEEE Transactions on Medical Imaging (TMI),\n22(1):22–28, 2003. 2\n[43] Tran Dinh Tien, Anh Tuan Nguyen, Nguyen Hoang Tran,\nTa Duc Huy, Soan Duong, Chanh D Tr Nguyen, and\nSteven QH Truong. Revisiting reverse distillation for\nanomaly detection. In IEEE/CVF Conference on Computer\nVision and Pattern Recognition (CVPR), 2023. 6\n[44] Wouter Van Gansbeke, Simon Vandenhende, Stamatios\nGeorgoulis, Marc Proesmans, and Luc Van Gool. Scan:\nLearning to classify images without labels. In European\nConference on Computer Vision (ECCV), 2020. 6\n[45] Sagar Vaze, Kai Han, Andrea Vedaldi, and Andrew Zisserman. Generalized category discovery. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),\n2022. 3, 5, 6, 7\n[46] Sagar Vaze, Andrea Vedaldi, and Andrew Zisserman. No\nrepresentation rules them all in category discovery. Advances\nin Neural Information Processing Systems (NeurIPS), 2023.\n2\n[47] Xin Wen, Bingchen Zhao, and Xiaojuan Qi. Parametric\nclassification for generalized category discovery: A baseline\nstudy. In IEEE/CVF International Conference on Computer\nVision (ICCV), 2023. 5, 6, 7\n[48] Weijia Wu, Yuzhong Zhao, Mike Zheng Shou, Hong Zhou,\nand Chunhua Shen. Diffumask: Synthesizing images with\npixel-level annotations for semantic segmentation using diffusion models. In IEEE/CVF International Conference on\nComputer Vision (ICCV), 2023. 2\n[49] Ruijie Xu, Chuyu Zhang, Hui Ren, and Xuming He. Duallevel adaptive self-labeling for novel class discovery in point\ncloud segmentation. In European Conference on Computer\nVision (ECCV). Springer, 2025. 2\n[50] Feng Xue, Anlong Ming, and Yu Zhou. A novel multi-layer\nframework for tiny obstacle discovery. In International Conference on Robotics and Automation (ICRA), 2019. 2\n[51] Feng Xue, Anlong Ming, and Yu Zhou. Tiny obstacle discovery by occlusion-aware multilayer regression. IEEE Transactions on Image Processing (TIP), 29:9373–9386, 2020.\n[52] Feng Xue, Yicong Chang, Tianxi Wang, Yu Zhou, and Anlong Ming. Indoor obstacle discovery on reflective ground\nvia monocular camera. International Journal of Computer\nVision (IJCV), 132(3):987–1007, 2024. 2\n[53] Zhaoyang Zeng, Bei Liu, Jianlong Fu, and Hongyang Chao.\nReference-based defect detection network. IEEE Transactions on Image Processing (TIP), 30:6637–6647, 2021. 1\n\n[25] Xu Ji, Joao F Henriques, and Andrea Vedaldi. Invariant information clustering for unsupervised image classification\nand segmentation. In IEEE/CVF International Conference\non Computer Vision (ICCV), 2019. 6\n[26] Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna,\nYonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and\nDilip Krishnan. Supervised contrastive learning. Advances\nin Neural Information Processing Systems (NeurIPS), 2020.\n5\n[27] Harold W Kuhn. The hungarian method for the assignment\nproblem. Naval Research Logistics Quarterly, 2(1-2):83–97,\n1955. 7\n[28] Yujin Lee, Harin Lim, Seoyoon Jang, and Hyunsoo Yoon.\nUniformaly: Towards task-agnostic unified framework for\nvisual anomaly detection. arXiv preprint arXiv:2307.12540,\n2023. 1, 2, 6\n[29] Hanxi Li, Jianfei Hu, Bo Li, Hao Chen, Yongbin Zheng, and\nChunhua Shen. Target before shooting: Accurate anomaly\ndetection and localization under one millisecond via cascade patch retrieval. IEEE Transactions on Image Processing\n(TIP), 33:5606–5621, 2024. 6, 7\n[30] Xurui Li, Ziming Huang, Feng Xue, and Yu Zhou. Musc:\nZero-shot industrial anomaly classification and segmentation with mutual scoring of the unlabeled images. In International Conference on Learning Representations (ICLR),\n2024. 6, 7\n[31] Yufei Liang, Jiangning Zhang, Shiwei Zhao, Runze Wu,\nYong Liu, and Shuwen Pan. Omni-frequency channelselection representations for unsupervised anomaly detection. IEEE Transactions on Image Processing (TIP), 32:\n4327–4340, 2023. 1\n[32] Christopher D Manning. An introduction to Information Retrieval (IR). 2009. 7\n[33] Chuang Niu, Jun Zhang, Ge Wang, and Jimin Liang. Gatcluster: Self-supervised gaussian-attention network for image clustering. In European Conference on Computer Vision\n(ECCV), 2020. 6\n[34] Konstantinos Ntirogiannis, Basilis Gatos, and Ioannis\nPratikakis. Performance evaluation methodology for historical document image binarization. IEEE Transactions on Image Processing (TIP), 22(2):595–609, 2013. 2\n[35] Nobuyuki Otsu. A threshold selection method from graylevel histograms. IEEE Transactions on Systems, Man, and\nCybernetics (TSMC), 9(1):62–66, 1979. 2, 7\n[36] William M Rand. Objective criteria for the evaluation of\nclustering methods. Journal of the American Statistical Association (JASA), 66(336):846–850, 1971. 7\n[37] Luigi Riz, Cristiano Saltori, Elisa Ricci, and Fabio Poiesi.\nNovel class discovery for 3d point cloud semantic segmentation. In IEEE/CVF Conference on Computer Vision and\nPattern Recognition (CVPR), 2023. 2\n[38] Karsten Roth, Latha Pemula, Joaquin Zepeda, Bernhard\nSchölkopf, Thomas Brox, and Peter Gehler. Towards total\nrecall in industrial anomaly detection. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),\n2022. 6\n[39] Sudipta Roy, Ayan Dey, Kingshuk Chatterjee, and Samir K\nBandyopadhyay. A new efficient binarization method for mri\n\n10\n\n\f[54] Zilong Zhang, Zhibin Zhao, Xingwu Zhang, Chuang Sun,\nand Xuefeng Chen. Industrial anomaly detection with domain shift: A real-world dataset and masked multi-scale reconstruction. Computers in Industry, 151:103990, 2023. 6\n[55] Yuyang Zhao, Zhun Zhong, Nicu Sebe, and Gim Hee\nLee. Novel class discovery in semantic segmentation. In\nIEEE/CVF Conference on Computer Vision and Pattern\nRecognition (CVPR), 2022. 2\n[56] Zhun Zhong, Linchao Zhu, Zhiming Luo, Shaozi Li, Yi\nYang, and Nicu Sebe. Openmix: Reviving known knowledge\nfor discovering novel visual categories in an open world.\nIn IEEE/CVF Conference on Computer Vision and Pattern\nRecognition (CVPR), 2021. 2\n[57] Huan Zhou, Feng Xue, Yucong Li, Shi Gong, Yiqun Li, and\nYu Zhou. Exploiting low-level representations for ultra-fast\nroad segmentation. IEEE Transactions on Intelligent Transportation Systems (TITS), pages 1–11, 2024. 2\n[58] Jiaying Zhou, Yang Liu, and Qingchao Chen. Novel class\ndiscovery in chest x-rays via paired images and text. In Proceedings of the AAAI Conference on Artificial Intelligence\n(AAAI), 2024. 2\n[59] Yu Zhou, Rui Lu, Feng Xue, and Yuzhe Gao. Occlusion relationship reasoning with a feature separation and interaction\nnetwork. Visual Intelligence, 1(1):23, 2023. 2\n\n11\n\n\fAnomalyNCD: Towards Novel Anomaly Class Discovery in Industrial Scenarios\nSupplementary Material\nOverview\n\nand unlabeled sub-images, we employ the self-supervised\ncontrastive loss Lrep as,\n\nIn this appendix, we provide additional descriptions of the\nfollowing contents:\n• Training details for novel class discovery (Sec. A).\n• The implementation details about our experiment settings\n(Sec. B).\n• The implementation details of our cropping method\n(Sec. C).\n• Discussion of the anomaly-centered sub-image cropping\n(Sec. D).\n• Discussion of the vision transformer under a supervised\nsetting (Sec. E).\n• Discussion of the labeled abnormal images (Sec. F).\n• Discussion on handling the combined category (Sec. G).\n• The computational analysis (Sec. H).\n• The analysis of model performance using ground truth\nmasks (Sec. I).\n• Ablation study on the number of threshold index in\nMEBin (Sec. J).\n• The sensitivity analysis of the hyperparameter τ in\nMEBin (Sec. K).\n• Sensitivity analysis of threshold 0.5 in PLC (Sec. L).\n• The binarization results of MEBin (Sec. M).\n• More detailed t-SNE visualizations (Sec. N).\n• More detailed quantitative results (Sec. O).\n• Limitation (Sec. P).\n\nLrep =\n\nexp(ẑ ⊤\n1 X\nj z̃ j /τu )\n− log P\n⊤\n|B|\nn∈Nj exp(ẑ j z̃ n /τu )\nj∈B\n\n(7)\n\nwhere B denotes a mini-batch. |B| represents the number of\nimage pairs in B. Nj indexes other image pairs in the batch\nexcept (x̂j , x̃j ), and τu is a temperature value. Similarly,\nthe supervised contrastive loss for labeled data is written as:\nexp(ẑ ⊤\n1 X 1 X\nj z̃ p /τc )\n−\nlog\nP\n⊤\nl\n|B |\n|Pj |\nn∈Nj exp(ẑ j z̃ n /τc )\np∈Pj\nj∈B l\n(8)\nwhere B l ⊂ B represents the indexes of labeled images in\nthe batch B. Pj indexes other images in the batch B which\nhave the same labels as x̂j and x̃j . τc is a temperature value.\nClassification learning. For each image pair (x̂j , x̃j ) in\na batch, we feed them into the teacher and student networks\nrespectively, which have shared MGViT and classification\nheads with different softmax temperatures. For labeled subimages, we convert the ground truth label into the one-hot\nl\nu\nvector ŷj = ỹj ∈ R1×(C +C ) , where the entry corresponding to the target class is set to 1 and all other entries are\n0. For unlabeled sub-images x̃j , x̂j , we generate pseudo\nlabels q̂j , q̃j by the “teacher” one, which employs a sharp\ntemperature τt to produce confident predictions. Specifically, following DINO [65], we compute the logits for two\nviews (x̂j , x̃j ) as ˆlj = H(f (x̂j )) and ˜lj = H(f (x̃j )), where\nˆlj , ˜lj ∈ R1×(C l +C u ) , f (·) indicates MGViT that outputs the\n[CLS] token, and H(·) is the linear classifier. Then, a softmax with temperature τt converts these logits into pseudo\nl\nu\nlabels q̂j , q̃j ∈ R1×(C +C ) as follows,\nLlrep =\n\nA. Training details for novel class discovery\nWe present concrete implementations of the novel class discovery paradigm used in our method. Following [? ? ], we\nemploy both classification learning and contrastive representation learning to train the network. For each sub-image\nxi,k , we use a new subscript j to replace i, k for a simple\nand clear description. Thus the augmented views of xj are\nformed as (x̃j , x̂j ). These views are fed into MGViT, denoted as f (·), to extract the [CLS] tokens.\n• For labeled sub-images, the ground truth labels are available. Therefore, we employ both self-supervised contrastive learning and supervised contrastive learning. In\naddition, supervised classification learning is performed\nby treating the ground truth labels as optimization targets.\n• For unlabeled sub-images, we use self-supervised contrastive representation learning. The pseudo labels are\ngenerated to perform classification learning.\nContrastive representation learning. The [CLS] tokens extracted by MGViT are fed into a three-layer MLP,\ndenoted as ϕ(·), to generate the image features from x̃j and\nx̂j : z̃ j = ϕ(f (x̃j )) and ẑ j = ϕ(f (x̂j )). For both labeled\n\n(k)\n\nq̂j\n(k)\n\n(k)\nexp(ˆlj /τt )\n= PC l +C u\n(k)\nexp(ˆlj /τt )\nk=1\n\n(9)\n\n(k)\n\nwhere q̂j and ˆlj denote the pseudo-label value and logit\nvalue respectively for the k-th class in C l + C u . Note that,\nwe set the logits ˜lj , ˆlj for C l known classes to −∞ to isolate\nknown classes when calculating pseudo labels. Then the\npseudo-label values for the known classes calculated by Eq.\n(9) are 0. The “student” one, using a smooth temperature\nl\nu\nτs , generates the probability predictions p̂j ∈ R1×(C +C )\nfor sub-image x̂j as,\n(k)\n\np̂j\n\n12\n\n(k)\nexp(ˆlj /τs )\n= PC l +C u\n(k)\nexp(ˆlj /τs )\nk=1\n\n(10)\n\n\f(k)\n\nwhere p̂j denotes the prediction probability for the k-th\nclass in C l + C u . The student network is trained to align p̂j ,\np̃j with either the ground truth labels (for labeled data) or\nthe pseudo labels (for unlabeled data). With the representation above, we leverage the standard cross-entropy loss\nPC l +C u −1 c\nLCE (p, q) = − c=0\np logq c to optimize the classification, which is represented as:\nImage\n\n1 X\n(LCE (ŷj , p̃j ) + LCE (ỹj , p̂j ))\nj∈B l\n|B l |\n1 X\n(LCE (q̂j , p̃j ) + LCE (q̃j , p̂j ))\nLu\ncls =\nj∈B u\n|B u |\n\nLlcls =\n\n(11)\n\nGT mask\n\nAttention (w crop)\n\nFigure 8. Visualization of [CLS] tokens’s attention for entire\nimage and sub-image.\n\n(12)\ntraining code, we directly use the official checkpoints on the\nMVTec AD dataset. EfficientAD does not release official\nimplementation, we use the unofficial version. For RD++\nand PNI, we conduct experiments on the MTD dataset according to the configuration of MVTec AD.\n\nwhere B u indexes the unlabeled images of the batch B.\nFinally, we adopt a mean-entropy maximization regularizer [64] Lu\nLCE (p̄j , p̄j ) for unlabeled sub-images,\nreg =P\nwhere p̄j = 2|B1 u | j∈B u (p̂j + p̃j ) denotes the mean prediction of unlabeled images. The overall loss of training\nobjective is written as:\nu\nL = λ(Llrep + Llcls ) + (1 − λ)(Lrep + Lu\ncls + µLreg )\n\nPredicted mask Attention (w/o crop)\n\nC. Implementation details of cropping\n\n(13)\n\nFor each region in Mu\ni , we set a square box that completely\nencloses this region but has minimal area. Then we extend\neach square box by adding a 10% padding. The padding\narea includes the background of anomalies and thus enables\nour network to extract features indicating the anomaly’s position on products, which is critical for classification. Notice that we keep the minimum crop size as 1% of the image\nsize. Finally, along each square box of Mu\ni , we crop a subimage from Iiu and its mask from Mu\n.\ni\n\nwhere λ is a hyperparameter that balances the supervised\nloss and the self-supervised loss. µ is the coefficient of the\nregularization.\n\nB. Additional implementation details\nWe use ViT-B/8 [67] pre-trained with DINO [65] as our feature extractor. The self-attentions in the last 9 layers are replaced with our mask-guided attention. During training, all\nthe layers of ViT are fixed except the last layer. As with\nUNO[68] and BYOP[78], we use the multi-head strategy in\nthe classifier H, and use the head with the smallest loss for\ninference. The input images are scaled to a resolution of\n224 × 224. We set the batch size to 32 and epochs to 50.\nThe Stochastic Gradient Descent (SGD) optimizer [63] is\nemployed with a learning rate of 0.003. To generate two\naugmented views for contrastive learning, we follow the\ndata augmentation strategies in BYOL [69] (random crop,\nflip, color jittering, and Gaussian blur) and RandAug [66]\n(rotation, posterize, and sharpness). Aligning with [? ], the\ntemperature values are set as follows: τu is 0.07 and τc is\n1.0, τs is set to 0.1 and τt is initialized to 0.07. For the first\n40 epochs, τt reduces every 4 epochs, linearly down to 0.04,\nthen stays the same. For our Main Element Binarization approach, we set the T to 64 and τ to 4. In the overall loss, the\nparameters λ and µ are set to 0.3 and 4 respectively. In the\nRegion Merging strategy, the temperature τα is set to 100\non the MVTec AD dataset and 50 on the MTD dataset.\nFor anomaly detection methods preceding AnomalyNCD, we choose zero-shot method MuSc [73], one-class\nmethods PatchCore [75], EfficientAD [61], RD++ [77], PNI\n[60] and CPR [72]. Note that CPR does not provide the\n\nD. Discussion of the anomaly-centered subimage cropping\nThe cropping operation plays a crucial role in industrial\nanomaly clustering for two primary reasons. First, many\nanomalies in industrial products are local and subtle. The\ncropping operation makes the anomalous region occupy\nmost of the image, which helps the network learn the\nanomaly easily. Second, the cropping operation can handle images with combined type anomalies, where there are\ndifferent types of anomalies in an image. More details about\ncombined type anomalies are given in Sec. G.\nAs shown in Fig. 8, for the original image, the attention of [CLS] token has a coarse-grained response in the\nanomalous region. When the anomaly is subtle, the discriminative features are hard to learn. For the sub-image, the\nattention has a fine-grained response and learns the more\ndiscriminative pixels of subtle anomaly. We report multiclass classification on the MVTec AD and MTD datasets\nin Table 8. Since anomalies on the MTD dataset are subtle and finer, the crop operation is required for fine-grained\nfeature learning, which can bring up to 23.8% NMI improvement for PatchCore+AnomalyNCD and 11.5% NMI\n13\n\n\fMuSc[73]+AnomalyNCD\n\nPatchCore[75]+AnomalyNCD\n\nEfficientAD[61]+AnomalyNCD\n\nPNI[60]+AnomalyNCD\n\nDataset\n\nSetting\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\nMVTec AD [62]\n\nw/o crop\nw crop\n\n0.622\n0.613\n\n0.549\n0.526\n\n0.740\n0.712\n\n0.650\n0.670\n\n0.584\n0.601\n\n0.755\n0.769\n\n0.501\n0.516\n\n0.396\n0.394\n\n0.637\n0.641\n\n0.676\n0.675\n\n0.616\n0.609\n\n0.777\n0.769\n\nMTD [70]\n\nw/o crop\nw crop\n\n0.086\n0.268\n\n0.076\n0.228\n\n0.374\n0.509\n\n0.142\n0.380\n\n0.166\n0.390\n\n0.432\n0.617\n\n0.105\n0.220\n\n0.066\n0.188\n\n0.379\n0.467\n\n0.107\n0.181\n\n0.134\n0.219\n\n0.407\n0.465\n\nTable 8. Ablation of Anomaly-Centered Sub-Image Cropping on the MVTec AD and MTD datasets.\nImage\nFPR\n\nDINO Supervised\nMG\nattention attention attention\n\nMVTec AD\n\nFNR\n\nw/o D\nw Dl\n(a)\n\n(b)\n\n(c)\n\n(d)\n\nl\n\nMTD\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\n0.583\n0.613\n\n0.506\n0.526\n\n0.689\n0.712\n\n0.227\n0.268\n\n0.202\n0.228\n\n0.485\n0.509\n\nTable 9. The ablation experiment of using labeled abnormal images Dl on the MVTec AD and MTD datasets.\n\nFigure 9. Ablation study on T Figure 10. Visualization of selfin MEBin.\nattention of the [CLS] token.\n\nF. Discussion of the labeled abnormal images\nHole\n\nCut\n\nCut\n\nPoke\n\nHole\n\nCut\n\nCut\n\nPoke\n\nCut\n\nCut\n\nPoke\n\nPoke\n\nResults with labeled data\n\nAs shown in Fig. 11, labeled data is significant for our\nmask-guided representation learning (MGRL). If only using unlabeled data, MGRL is prone to confuse anomalies\nwith highly similar appearances. For example, a “Hole” on\na carpet is treated as “Cut”, and “Cut” on leather is misclassified as a “Poke”. Actually, even humans tend to confuse\nthem. With the supervision of labeled data, confusion does\nnot occur. The reason is that the labeled data helps to build\nthe feature space of prior classes, so that even the subtle\ndifferences from novel classes can be recognized.\nIn the labeled abnormal images Dl , there is much prior\nknowledge of industrial anomalies classification, such as\nanomalies with similar size, color, and location belonging\nto the same class. Using them to train the network together\ncan transfer the knowledge from Dl to the network and separate confusing anomalies from each other in Du . We report\nthe quantitative results in Table 9, using Dl brings 3.0%\nNMI improvements on MVTec AD and 3.9 % NMI improvements on MTD. In addition, we also use 15 categories\nin the MVTec AD dataset as the labeled abnormal images\nin turn. Except for the toothbrush category, which has only\none anomaly class. The quantitative results are reported in\nTables 10 to 12. MuSc is used as the anomaly detection\nmethod by default.\n\nResults without labeled data\n\nFigure 11. Impact of using or not using labeled data. We show\ntwo product cases, and each presents two similar anomalies.\n\ngains for EfficientAD+AnomalyNCD. On the MVTec AD\ndataset, the crop operation results in a 2.0% NMI increase\nfor PatchCore+AnomalyNCD and 1.5% NMI gain for EfficientAD+AnomalyNCD. When using MuSc or PNI as the\nanomaly detection method, it only decreases NMI by 0.9%\nat most.\n\nE. Discussion of ViT under a supervised setting\nTo study the ability of the vision transformer (ViT) to focus\non local anomalies under a supervised setting, we leave one\nout cross validation. As shown in the attention maps of Fig.\n10, the supervised training could focus on the anomaly regions, while it needs manually collecting and labeling the\nabnormal samples, which is time-consuming. As shown in\n(c) and (d), our AnomalyNCD leverages self-supervision to\nreduce these manual operations while also focuses attention\non the anomalies, which is more suitable for industrial scenarios.\n\nG. Discussion on handling the combined category\nIn main experiments, we follow Anomaly Clustering [76]\nto remove the combined class for a fair comparison. However, the combined class is quite common in the industrial\nscene, such as the cable, pill, wood, and zipper products on\nthe MVTec AD dataset. The image with the combined class\n14\n\n\ftrain \\ test bottle cable capsule carpet grid hazelnut leather metal nut\n\npill\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntransistor\nwood\nzipper\nmean\n\n0.561\n0.676\n0.614 0.604\n0.564 0.571\n0.552 0.520\n0.535 0.616\n0.639 0.603\n0.598 0.556\n0.603 0.594\n0.569 0.559\n0.514 0.587\n0.499 0.607\n0.586 0.633\n0.627 0.555\n\nscrew\n\ntile\n\ntoothbrush transistor wood zipper mean\n\n0.483\n0.522\n0.503\n0.460\n0.451\n0.443\n0.575\n0.430\n0.486\n0.506\n0.420\n0.472\n0.395\n\n0.840 0.593\n0.862 0.699\n0.714 0.652\n0.624\n0.790\n0.731 0.660\n0.755 0.597\n0.863 0.723\n0.850 0.641\n0.746 0.501\n0.762 0.501\n0.645 0.569\n0.764 0.655\n0.795 0.616\n\n0.727\n0.695\n0.715\n0.714\n0.747\n0.740\n0.684\n0.753\n0.688\n0.750\n0.699\n0.708\n0.723\n\n0.623\n0.784\n0.724\n0.818\n0.714\n0.640\n0.838\n0.763\n0.815\n0.790\n0.651\n0.700\n0.765\n\n0.744\n0.799\n0.674\n0.745\n0.707\n0.799\n0.658\n0.728\n0.787\n0.725\n0.768\n0.789\n0.755\n\n0.434 0.339 0.867\n0.396 0.435 0.858\n0.412 0.433 0.719\n0.416 0.418 0.885\n0.441 0.361 0.794\n0.401 0.351 0.824\n0.439 0.419 0.885\n0.463 0.355 0.811\n0.398 0.885\n0.433\n0.895\n0.425 0.414\n0.446 0.387 0.738\n0.402 0.354 0.767\n0.432 0.412 0.803\n\n0.269\n0.341\n0.242\n0.218\n0.218\n0.299\n0.368\n0.242\n0.368\n0.368\n0.242\n0.299\n0.218\n0.398\n\n0.535\n0.511\n0.498\n0.508\n0.517\n0.513\n0.507\n0.521\n0.543\n0.493\n0.483\n0.482\n0.543\n\n0.731 0.442\n0.640 0.545\n0.702 0.586\n0.681 0.541\n0.680 0.555\n0.712 0.493\n0.663 0.570\n0.617 0.559\n0.678 0.518\n0.685 0.542\n0.693 0.548\n0.445 0.553\n0.533\n0.658\n-\n\n0.585\n0.626\n0.603\n0.586\n0.575\n0.573\n0.592\n0.600\n0.625\n0.612\n0.565\n0.552\n0.576\n0.606\n\n0.583 0.582 0.473\n\n0.778 0.618\n\n0.719\n\n0.740\n\n0.744\n\n0.426 0.390 0.825\n\n0.292\n\n0.512\n\n0.660 0.537 0.591\n\nTable 10. The detailed NMI metric evaluated on different labeled abnormal images Dl on the MVTec AD dataset.\ntrain \\ test bottle cable capsule carpet grid hazelnut leather metal nut\n\npill\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntransistor\nwood\nzipper\nmean\n\n0.608\n0.643\n0.554 0.628\n0.495 0.602\n0.532 0.580\n0.474 0.643\n0.586 0.643\n0.562 0.482\n0.562 0.501\n0.519 0.618\n0.478 0.635\n0.467 0.544\n0.539 0.639\n0.571 0.476\n\nscrew\n\ntile\n\ntoothbrush transistor wood zipper mean\n\n0.402\n0.384\n0.352\n0.313\n0.361\n0.295\n0.452\n0.303\n0.334\n0.367\n0.313\n0.370\n0.268\n\n0.778 0.457\n0.783 0.625\n0.600 0.585\n0.546\n0.696\n0.679 0.610\n0.688 0.533\n0.789 0.664\n0.791 0.549\n0.707 0.394\n0.697 0.420\n0.551 0.496\n0.684 0.599\n0.769 0.566\n\n0.704\n0.712\n0.705\n0.715\n0.744\n0.717\n0.702\n0.763\n0.707\n0.745\n0.700\n0.719\n0.740\n\n0.569\n0.689\n0.648\n0.789\n0.672\n0.581\n0.765\n0.671\n0.743\n0.679\n0.588\n0.620\n0.726\n\n0.623\n0.659\n0.544\n0.606\n0.563\n0.659\n0.515\n0.573\n0.675\n0.570\n0.640\n0.656\n0.629\n\n0.325 0.242 0.816\n0.267 0.297 0.835\n0.302 0.320 0.575\n0.289 0.315 0.830\n0.318 0.257 0.744\n0.262 0.257 0.781\n0.298 0.310 0.830\n0.313 0.301 0.773\n0.273 0.830\n0.286\n0.849\n0.278 0.322\n0.296 0.301 0.670\n0.285 0.232 0.732\n0.274 0.286 0.747\n\n0.259\n0.210\n0.211\n0.167\n0.167\n0.312\n0.259\n0.211\n0.259\n0.259\n0.211\n0.312\n0.167\n0.313\n\n0.442\n0.474\n0.411\n0.460\n0.471\n0.430\n0.407\n0.428\n0.464\n0.416\n0.380\n0.416\n0.455\n\n0.660 0.322\n0.478 0.404\n0.633 0.445\n0.599 0.409\n0.555 0.430\n0.617 0.378\n0.569 0.416\n0.486 0.422\n0.608 0.395\n0.635 0.437\n0.570 0.429\n0.347 0.401\n0.395\n0.585\n-\n\n0.515\n0.533\n0.517\n0.512\n0.503\n0.503\n0.505\n0.525\n0.539\n0.541\n0.477\n0.473\n0.504\n0.529\n\n0.537 0.585 0.347\n\n0.709 0.542\n\n0.721\n\n0.672\n\n0.609\n\n0.292 0.286 0.770\n\n0.237\n\n0.435\n\n0.565 0.406 0.513\n\nTable 11. The detailed ARI metric evaluated on different labeled abnormal images Dl on the MVTec AD dataset.\n\ntrain \\ test bottle cable capsule carpet grid hazelnut leather metal nut\n\npill\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntransistor\nwood\nzipper\nmean\n\n0.655\n0.843\n0.795 0.676\n0.747 0.640\n0.795 0.640\n0.699 0.705\n0.807 0.676\n0.807 0.619\n0.807 0.626\n0.783 0.647\n0.759 0.691\n0.675 0.647\n0.795 0.683\n0.807 0.633\n\nscrew\n\ntile\n\ntoothbrush transistor wood zipper mean\n\n0.636\n0.636\n0.644\n0.614\n0.636\n0.553\n0.652\n0.576\n0.652\n0.667\n0.591\n0.629\n0.545\n\n0.821 0.641\n0.812 0.795\n0.709 0.718\n0.705\n0.778\n0.778 0.782\n0.795 0.679\n0.803 0.833\n0.838 0.718\n0.795 0.577\n0.735 0.564\n0.658 0.667\n0.761 0.769\n0.846 0.705\n\n0.809\n0.827\n0.782\n0.782\n0.818\n0.791\n0.800\n0.864\n0.773\n0.818\n0.800\n0.800\n0.836\n\n0.661\n0.766\n0.694\n0.847\n0.774\n0.694\n0.798\n0.742\n0.774\n0.750\n0.702\n0.702\n0.823\n\n0.678\n0.687\n0.617\n0.661\n0.617\n0.687\n0.617\n0.643\n0.704\n0.617\n0.678\n0.687\n0.687\n\n0.500 0.450 0.923\n0.460 0.513 0.932\n0.480 0.513 0.740\n0.453 0.506 0.932\n0.507 0.456 0.855\n0.453 0.475 0.889\n0.487 0.525 0.932\n0.533 0.513 0.880\n0.488 0.932\n0.507\n0.940\n0.447 0.506\n0.513 0.506 0.786\n0.493 0.444 0.855\n0.467 0.494 0.880\n\n0.762\n0.738\n0.738\n0.714\n0.714\n0.786\n0.762\n0.738\n0.762\n0.762\n0.738\n0.786\n0.714\n0.786\n\n0.640\n0.620\n0.630\n0.630\n0.660\n0.620\n0.620\n0.630\n0.620\n0.620\n0.600\n0.630\n0.630\n\n0.853 0.489\n0.662 0.600\n0.838 0.681\n0.824 0.607\n0.794 0.652\n0.829 0.533\n0.809 0.644\n0.647 0.622\n0.838 0.600\n0.838 0.652\n0.794 0.645\n0.618 0.637\n0.607\n0.824\n-\n\n0.778 0.657 0.618\n\n0.779 0.704\n\n0.808\n\n0.748\n\n0.660\n\n0.485 0.491 0.883\n\n0.750\n\n0.627\n\n0.782 0.613 0.694\n\nTable 12. The detailed F1 metric evaluated on different labeled abnormal images Dl on the MVTec AD dataset.\n\n15\n\n0.680\n0.706\n0.702\n0.692\n0.691\n0.683\n0.693\n0.705\n0.718\n0.716\n0.665\n0.662\n0.684\n0.712\n\n\fSub-image\n1\n\nImage\n\nSub-image\n2\n\nSub-image\n1\n\nfabric_border\n\n0.73\n\nfabric_interior\n\ncrack\n\n0.57\n\ncombined\n\nImage\n\nSub-image\n2\n\nfaulty_imprint\n\ncombined\n\n0.49\n\n0.33 0.32\n\n(a) Zipper Product\n\n0.45\n\n0.33\n\n0.21\n\n(b) Pill Product\n\nFigure 12. Multi-class classification results of two combined-type anomaly images. Taking “zipper” and “pill” as examples, we show\nthe predicted probabilities for each sub-image individually and for the entire image.\n\nTime (ms)\n\n(II)\n\n(III)\n\n(IV)\n\nTotal\n\n129.8\n\n22.8\n\n0.5\n\n153.1\n\nMVTec AD\n\nTable 13. Inference time for each module on a per-image basis.\n\nMTD\n\nMethods\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\nAC [76]\nOurs\n\n0.711\n0.871\n\n0.638\n0.851\n\n0.718\n0.909\n\n0.467\n0.829\n\n0.359\n0.863\n\n0.482\n0.841\n\nTable 14. The quantitative results of using the ground truth masks.\nWe compare our AnomalyNCD with Anomaly Clustering on the\nMVTec AD and MTD datasets.\n\ncontains multiple different types of anomalies, yet current\nclustering methods can only classify the entire image into\none anomaly type. For our method, we crop the image into\nmany sub-images, and the classifier assigns each sub-image\na label. In this way, all the anomalous regions in the combined image can be found and classified individually. As\nshown in Fig. 12, there are two types of anomalies in the\nzipper and pill products respectively. Each anomalous region is cropped and correctly classified. By merging the\nprediction of the sub-images to the entire image, we find\nthat classifying the image as these two types of anomalies\nhas a higher probability.\n\nI. Analysis of model performance using ground\ntruth masks\nIn the experimental section, we demonstrate that our multiclass classification performs better when the anomaly detection method performs better. So in order to test the\noptimal results of our AnomalyNCD, we assume an ideal\nanomaly detection method where the ground truth masks\nof unlabeled images are available. We report the results in\nTable 14, our approach achieves significant improvement\nover Anomaly Clustering on two datasets. On MVTec AD,\nthere is a 16.0% improvement on the NMI and a 19.1% improvement on the F1 , and on MTD, there is a 36.2% improvement on the NMI and a 35.9% improvement on the\nF1 . In this ideal case, ground truth masks do not introduce any over-detections and missed detections compared\nto anomaly maps generated by anomaly detection methods.\nWith the improvement of anomaly detection methods in the\nfuture, our AnomalyNCD can achieve better results.\n\nH. Computational analysis\nWe measure the inference speed of AnomalyNCD on an\nNVIDIA RTX 3090 GPU. The entire inference process\nconsists of four steps: (I) applying an anomaly detection\nmethod to the input image, (II) binarizing the anomaly map\nand cropping sub-images accordingly, (III) feeding these\nsub-images and their corresponding masks into our maskguided ViT and getting probability output, and (IV) merging predictions from each sub-image to generate the final\noutput. Table 13 presents the per-image inference time for\neach step. Note that the time taken for step (I) depends on\nthe anomaly detection method and is independent of our\nAnomalyNCD. The majority of the inference time is concentrated in the MEBin and image cropping, which account\nfor over 80% of the total runtime. MEBin uses the official\nOpenCV library for connection component calculations, resulting in the inability to use CUDA acceleration.\n\nJ. Ablation study on the number of threshold\nindex in MEBin\nIn Fig. 9, we conduct the ablation study on the number of\nthreshold index T . Note that we use powers of 2 for candidates of T , since it is calculated on grayscale images (0255). T = 64 achieves better FPR-FNR trade-off compared\nto other T . With a small value (T = 32), the binary mask\n16\n\n\fPLC Thresholds\n0.1\n0.3\n0.5\n0.7\n0.9\n\nMVTec AD - MuSc\n0.602/0.522/0.715\n0.615/0.533/0.727\n0.613/0.526/0.712\n0.630/0.557/0.731\n0.584/0.476/0.682\n\nMTD - MuSc\n0.212/0.180/0.419\n0.230/0.204/0.487\n0.268/0.228/0.509\n0.257/0.212/0.489\n0.231/0.172/0.489\n\nMVTec AD - RD++\n0.625/0.531/0.717\n0.627/0.545/0.721\n0.631/0.542/0.721\n0.650/0.561/0.741\n0.604/0.487/0.682\n\nMTD - RD++\n0.368/0.377/0.587\n0.391/0.382/0.595\n0.368/0.361/0.600\n0.353/0.333/0.566\n0.337/0.302/0.549\n\nMVTec AD - PatchCore\n0.630/0.574/0.734\n0.646/0.594/0.757\n0.670/0.601/0.769\n0.653/0.578/0.748\n0.506/0.338/0.610\n\nMTD - PatchCore\n0.457/0.453/0.683\n0.466/0.452/0.683\n0.380/0.390/0.715\n0.602/0.415/0.664\n0.423/0.352/0.660\n\nRank\n3.44\n2.28\n2.17\n2.22\n4.67\n\nTable 15. The results (NMI, ARI, F1) on two datasets, when taking various PLC thresholds. Rank is the average ranking of the threshold.\n\nMuSc[73]+AnomalyNCD\n\nImage\n\nCPR[72]+AnomalyNCD\n\nNMI\n\nARI\n\nF1\n\nNMI\n\nARI\n\nF1\n\nτ =2\nτ =3\nτ =4\nτ =5\nτ =6\n\n0.640\n0.647\n0.613\n0.618\n0.600\n\n0.537\n0.543\n0.526\n0.539\n0.510\n\n0.707\n0.718\n0.712\n0.740\n0.715\n\n0.720\n0.736\n0.736\n0.721\n0.710\n\n0.647\n0.668\n0.674\n0.665\n0.655\n\n0.787\n0.797\n0.805\n0.807\n0.799\n\nvariance\n\n0.0003\n\n0.0001\n\n0.0001\n\n0.0001\n\n0.0001\n\n0.0001\n\nGT mask\n\nBinarization\n\nAnomaly map\nMEBin\n\n(a) 0.04\n\n0.56\n\nFNR: 1.22%\nFPR: 0.69%\n\n0.0\n\nTable 16. Sensitivity analysis of the minimum stable range τ in\nMEBin. We use the zero-shot AD method MuSc and one-class\nAD method CPR to conduct experiments.\n\nanomaly probability\nImage\n\nGT mask\n\n1.0\n\nAnomaly map\n\nBinarization\nMEBin\n\nchanges dramatically, making it difficult to determine a stable connected component. Conversely, a larger T brings\nmore time consumption. Therefore, we set T = 64 as the\ndefault value.\n\n(b) 0.04 0.12\n\nK. Sensitivity analysis of τ in MEBin\n\n0.0\n\nIn Table 16, we experiment with the parameter sensitivity\nof the minimum stable range τ on the MVTec AD dataset.\nWe use the zero-shot anomaly detection method MuSc [73]\nand the one-class method CPR [72] respectively to combine with our AnomalyNCD. When the hyperparameter τ\nis changed, the multi-class anomaly classification results\nchange with a variance of about 0.0001, demonstrating that\nour method is insensitive to τ .\n\nnormal\nabnormal\noverlap\n\nanomaly probability\n\nFNR: 100%\nFPR: 1.0\n\nFigure 13. Analysis of anomaly maps in EfficientAD. We visualize the pixel-level anomaly probability histogram, and use dashed\nlines to represent the average anomaly probability for normal and\nanomalous regions respectively.\n\nthe optimal threshold for each image with fewer false positives and false negatives. Compared to the Otsu method, our\nMEBin has fewer false positives, especially on normal images. We also report the optimal threshold searched by our\nMEBin in the last column of Fig. 16 to Fig. 18. The optimal\nthreshold ranges from 0.380 to 1.000, making it difficult to\nhandle all situations with a fixed threshold.\n\nL. Sensitivity analysis of threshold 0.5 in PLC\nAlthough MEBin achieves a decent trade-off, it may still\nget over-detections due to local noises. Thus, PLC uses\nthe threshold 0.5 to find over-detections and corrects their\npseudo label with a normal one-hot label. The optimal PLC\nthreshold is related to datasets and anomaly detection methods. Tab. 15 shows the results of three methods on two\ndatasets, when taking various PLC thresholds. Observably,\na threshold of 0.5 ranks 1st performance on average in all\ncandidates.\n\nN. Detailed t-SNE visualization\nIn Fig. 14, we show more t-SNE visualization on all the\nproducts of the MVTec AD dataset. We also provide more\nqualitative comparisons with AC [76] and Uniformaly [71]\nin Fig. 15. These methods show slight clustering phenomena, while our AnomalyNCD has larger inter-class distances and smaller intra-class distances. This further proves\nthe superiority of our method from the qualitative perspective.\n\nM. Binarization results of MEBin\nFrom Fig. 16 to Fig. 18, we binarize the anomaly maps output by MuSc [73] using different binarization strategies, including the fixed threshold, the Otsu [74] method, and our\nMEBin. Our binarization strategy does not require the validation set to determine a threshold and adaptively obtain\n17\n\n\fO. Detailed quantitative results\nIn this section, we report the detailed results of our AnomalyNCD combined with various anomaly detection methods\non the MVTec AD dataset, as shown in Table 17.\n\nP. Limitation\nThe anomaly detection methods used affect the performance of our AnomalyNCD. In general, if the anomaly\ndetection method has a higher AUPRO, we can achieve a\nbetter performance in the multi-class anomaly classification task. In the ideal situation where the ground truth\nmask is available (AUPRO=100%), our AnomalyNCD is\nsignificantly superior to other methods, which has been discussed in Sec. I. However, EfficientAD [61] is an exception, with a lower multi-class anomaly classification performance despite higher AUPRO. We observe that a large\nspan of anomaly probability values exists between different anomaly maps generated by EfficientAD, as shown in\nFig. 13. The average value of the anomalous region in (a)\nis only 0.12, which is close to the anomaly probability in\nthe normal region, while that in (b) is 0.56. This large span\ncauses false negatives in (a) during binarization, resulting in\na lower performance for anomaly classification.\n\nMethods\nProducts\\Metric\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nMean\n\nMuSc[73]\n+AnomalyNCD\nNMI\nARI\nF1\n\nPatchCore[75]\n+AnomalyNCD\nNMI\nARI\nF1\n\nEfficientAD[61]\n+AnomalyNCD\nNMI\nARI\nF1\n\nRD++[77]\n+AnomalyNCD\nNMI\nARI\nF1\n\nPNI[60]\n+AnomalyNCD\nNMI\nARI\nF1\n\nCPR[72]\n+AnomalyNCD\nNMI\nARI\nF1\n\n0.613\n0.597\n0.445\n0.852\n0.622\n0.662\n0.863\n0.643\n0.439\n0.399\n0.885\n0.368\n0.531\n0.743\n0.526\n0.613\n\n0.734\n0.758\n0.402\n0.628\n0.670\n0.859\n0.770\n0.910\n0.476\n0.638\n0.927\n0.271\n0.642\n0.782\n0.583\n0.670\n\n0.544\n0.549\n0.519\n0.672\n0.684\n0.570\n0.587\n0.436\n0.388\n0.594\n0.523\n0.398\n0.439\n0.375\n0.455\n0.516\n\n0.640\n0.679\n0.481\n0.599\n0.631\n0.845\n0.746\n0.851\n0.467\n0.615\n0.757\n0.316\n0.477\n0.750\n0.608\n0.631\n\n0.676\n0.765\n0.425\n0.619\n0.583\n0.919\n0.672\n0.891\n0.461\n0.640\n1.000\n0.271\n0.716\n0.850\n0.639\n0.675\n\n0.775\n0.711\n0.549\n0.740\n0.766\n0.723\n0.865\n0.870\n0.694\n0.742\n0.98\n0.508\n0.577\n0.816\n0.726\n0.736\n\n0.583\n0.492\n0.335\n0.837\n0.578\n0.582\n0.838\n0.467\n0.291\n0.265\n0.850\n0.259\n0.421\n0.672\n0.417\n0.526\n\n0.819\n0.626\n0.591\n0.906\n0.731\n0.718\n0.911\n0.565\n0.513\n0.488\n0.940\n0.762\n0.620\n0.868\n0.615\n0.712\n\n0.671\n0.666\n0.277\n0.569\n0.581\n0.875\n0.734\n0.883\n0.335\n0.569\n0.912\n0.084\n0.693\n0.644\n0.518\n0.601\n\n0.855\n0.741\n0.530\n0.726\n0.731\n0.927\n0.839\n0.948\n0.567\n0.756\n0.966\n0.667\n0.760\n0.868\n0.652\n0.769\n\n0.467\n0.414\n0.402\n0.577\n0.570\n0.429\n0.449\n0.272\n0.194\n0.498\n0.375\n0.313\n0.462\n0.196\n0.291\n0.394\n\n0.759\n0.619\n0.644\n0.726\n0.795\n0.673\n0.621\n0.443\n0.460\n0.719\n0.598\n0.786\n0.650\n0.574\n0.548\n0.641\n\n0.529\n0.602\n0.392\n0.527\n0.544\n0.853\n0.688\n0.821\n0.286\n0.551\n0.711\n0.164\n0.292\n0.651\n0.515\n0.542\n\n0.771\n0.734\n0.606\n0.658\n0.615\n0.909\n0.782\n0.922\n0.527\n0.725\n0.795\n0.714\n0.500\n0.868\n0.689\n0.721\n\nTable 17. Detailed quantitative results on the MVTec AD dataset.\n\n18\n\n0.598\n0.601\n0.338\n0.548\n0.534\n0.926\n0.616\n0.872\n0.315\n0.616\n1.000\n0.084\n0.743\n0.790\n0.552\n0.609\n\n0.819\n0.691\n0.568\n0.701\n0.705\n0.955\n0.734\n0.948\n0.580\n0.769\n1.000\n0.667\n0.820\n0.927\n0.659\n0.769\n\n0.757\n0.476\n0.438\n0.638\n0.689\n0.727\n0.827\n0.848\n0.592\n0.698\n0.976\n0.499\n0.523\n0.756\n0.667\n0.674\n\n0.904\n0.561\n0.674\n0.795\n0.731\n0.827\n0.895\n0.930\n0.747\n0.800\n0.992\n0.857\n0.700\n0.912\n0.756\n0.805\n\n\fw/o MG\nw/ MG\n\ncable\n\ncapsule\n\ncarpet\n\ngrid\n\nleather\n\npill\n\nscrew\n\ntile\n\ntoothbrush\n\ntransistor\n\nzipper\n\nw/ MG\n\nw/o MG\n\nbottle\n\nOurs\n\nAC\n\nUniformaly\n\nFigure 14. T-SNE visualization of sub-images on the MVTec AD dataset. The different colors of dots represent their anomaly classes.\n\nmetal nut\n\nhazelnut\n\nwood\n\ncarpet\n\nleather\n\nFigure 15. Qualitative comparisons with different clustering methods by t-SNE visualization.\n\n19\n\ntile\n\n\fBottle\n\n0.549\n\nBottle\n\n0.490\n\nCable\n\nMEBin\n\n1.000\n\nCable\n\nTHR=0.7\n\n0.592\n\nCapsule\n\nTHR=0.5\n\n0.380\n\nCapsule\n\nTHR=0.3\n\n0.431\n\nCarpet\n\nOtsu\n\n0.435\n\nCarpet\n\nAnomaly map\n\n0.529\n\nGrid\n\nGT\n\n0.573\n\nGrid\n\nImage\n\n0.553\n\nFigure 16. Binarization results of MEBin on the MVTec AD dataset. We show for each category: RGB image, ground truth, anomaly\nmap, binary map of Otsu method, binary map of fixed threshold 0.3, binary map of fixed threshold 0.5, binary map of fixed threshold 0.7,\nand binary map of our MEBin. We report the optimal threshold searched by our MEBin in the last column.\n\n20\n\n\fHazelnut\n\n0.592\n\nHazelnut\n\n0.592\n\nLeather\n\nMEBin\n\n0.624\n\nLeather\n\nTHR=0.7\n\n0.545\n\nMetal nut\n\nTHR=0.5\n\n0.561\n\nMetal nut\n\nTHR=0.3\n\n0.604\n\nPill\n\nOtsu\n\n0.537\n\nPill\n\nAnomaly map\n\n0.553\n\nScrew\n\nGT\n\n0.749\n\nScrew\n\nImage\n\n0.745\n\nFigure 17. Binarization results of MEBin on the MVTec AD dataset. We show for each category: RGB image, ground truth, anomaly\nmap, binary map of Otsu method, binary map of fixed threshold 0.3, binary map of fixed threshold 0.5, binary map of fixed threshold 0.7,\nand binary map of our MEBin. We report the optimal threshold searched by our MEBin in the last column.\n\n21\n\n\fTile\n\n0.494\n\nTile\n\n0.580\n\ntoothbrush\n\nMEBin\n\n0.600\n\ntoothbrush\n\nTHR=0.7\n\n1.000\n\ntransistor\n\nTHR=0.5\n\n0.565\n\ntransistor\n\nTHR=0.3\n\n0.576\n\nwood\n\nOtsu\n\n1.000\n\nwood\n\nAnomaly map\n\n0.541\n\nzipper\n\nGT\n\n0.494\n\nzipper\n\nImage\n\n0.600\n\nFigure 18. Binarization results of MEBin on the MVTec AD dataset. We show for each category: RGB image, ground truth, anomaly\nmap, binary map of Otsu method, binary map of fixed threshold 0.3, binary map of fixed threshold 0.5, binary map of fixed threshold 0.7,\nand binary map of our MEBin. We report the optimal threshold searched by our MEBin in the last column.\n\n22\n\n\fReferences\n\nBernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent-a new approach\nto self-supervised learning. Advances in Neural Information\nProcessing Systems (NeurIPS), 2020.\n[70] Yibin Huang, Congying Qiu, and Kui Yuan. Surface defect\nsaliency of magnetic tile. The Visual Computer, 36(1):85–\n96, 2020.\n[71] Yujin Lee, Harin Lim, Seoyoon Jang, and Hyunsoo Yoon.\nUniformaly: Towards task-agnostic unified framework for\nvisual anomaly detection. arXiv preprint arXiv:2307.12540,\n2023.\n[72] Hanxi Li, Jianfei Hu, Bo Li, Hao Chen, Yongbin Zheng, and\nChunhua Shen. Target before shooting: Accurate anomaly\ndetection and localization under one millisecond via cascade patch retrieval. IEEE Transactions on Image Processing\n(TIP), 33:5606–5621, 2024.\n[73] Xurui Li, Ziming Huang, Feng Xue, and Yu Zhou. Musc:\nZero-shot industrial anomaly classification and segmentation with mutual scoring of the unlabeled images. In International Conference on Learning Representations (ICLR),\n2024.\n[74] Nobuyuki Otsu. A threshold selection method from graylevel histograms. IEEE Transactions on Systems, Man, and\nCybernetics (TSMC), 9(1):62–66, 1979.\n[75] Karsten Roth, Latha Pemula, Joaquin Zepeda, Bernhard\nSchölkopf, Thomas Brox, and Peter Gehler. Towards total\nrecall in industrial anomaly detection. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),\n2022.\n[76] Kihyuk Sohn, Jinsung Yoon, Chun-Liang Li, Chen-Yu Lee,\nand Tomas Pfister. Anomaly clustering: Grouping images\ninto coherent clusters of anomaly types. In IEEE/CVF Winter Conference on Applications of Computer Vision (WACV),\n2023.\n[77] Tran Dinh Tien, Anh Tuan Nguyen, Nguyen Hoang Tran,\nTa Duc Huy, Soan Duong, Chanh D Tr Nguyen, and\nSteven QH Truong. Revisiting reverse distillation for\nanomaly detection. In IEEE/CVF Conference on Computer\nVision and Pattern Recognition (CVPR), 2023.\n[78] Muli Yang, Liancheng Wang, Cheng Deng, and Hanwang\nZhang. Bootstrap your own prior: Towards distributionagnostic novel class discovery. In IEEE/CVF Conference on\nComputer Vision and Pattern Recognition (CVPR), 2023.\n\n[60] Jaehyeok Bae, Jae-Han Lee, and Seyun Kim. Pni: industrial anomaly detection using position and neighborhood information. In IEEE/CVF International Conference on Computer Vision (ICCV), 2023.\n[61] Kilian Batzner, Lars Heckler, and Rebecca König. Efficientad: Accurate visual anomaly detection at millisecond-level\nlatencies. In IEEE/CVF Winter Conference on Applications\nof Computer Vision (WACV), 2024.\n[62] Paul Bergmann, Michael Fauser, David Sattlegger, and\nCarsten Steger. Mvtec ad–a comprehensive real-world\ndataset for unsupervised anomaly detection. In IEEE/CVF\nConference on Computer Vision and Pattern Recognition\n(CVPR), 2019.\n[63] Léon Bottou. Large-scale machine learning with stochastic\ngradient descent. In International Conference on Computational Statistics (COMPSTAT), 2010.\n[64] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning\nof visual features by contrasting cluster assignments. Advances in Neural Information Processing Systems (NeurIPS),\n2020.\n[65] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou,\nJulien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In\nIEEE/CVF International Conference on Computer Vision\n(ICCV), 2021.\n[66] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V\nLe. Randaugment: Practical automated data augmentation\nwith a reduced search space. In IEEE/CVF Conference on\nComputer Vision and Pattern Recognition Workshop (CVPR\nWorkshop), 2020.\n[67] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov,\nDirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner,\nMostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.\n[68] Enrico Fini, Enver Sangineto, Stéphane Lathuiliere, Zhun\nZhong, Moin Nabi, and Elisa Ricci. A unified objective for\nnovel class discovery. In IEEE/CVF International Conference on Computer Vision (ICCV), 2021.\n[69] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin\nTallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch,\n\n23\n\n\f</code></pre></article>\n        \n</main>\n\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js\"></script>\n<script>\n\nfunction initTheme() {\n  const saved = localStorage.getItem('kb-theme') || 'light';\n  document.documentElement.setAttribute('data-theme', saved);\n  updateThemeIcon(saved);\n}\nfunction toggleTheme() {\n  const cur = document.documentElement.getAttribute('data-theme') || 'light';\n  const next = cur === 'light' ? 'dark' : 'light';\n  document.documentElement.setAttribute('data-theme', next);\n  localStorage.setItem('kb-theme', next);\n  updateThemeIcon(next);\n}\nfunction updateThemeIcon(t) {\n  const btn = document.getElementById('theme-toggle-btn');\n  if (btn) btn.innerHTML = t === 'dark' ? '☀️' : '🌙';\n}\ndocument.addEventListener('DOMContentLoaded', initTheme);\n\nfunction setViewMode(m) {\n  const grid = document.getElementById('bento-grid-view');\n  const list = document.getElementById('list-table-view');\n  const bGrid = document.getElementById('view-grid-btn');\n  const bList = document.getElementById('view-list-btn');\n  if (m === 'list') {\n    if (grid) grid.style.display = 'none';\n    if (list) list.style.display = 'flex';\n    if (bGrid) bGrid.classList.remove('active');\n    if (bList) bList.classList.add('active');\n  } else {\n    if (grid) grid.style.display = 'grid';\n    if (list) list.style.display = 'none';\n    if (bGrid) bGrid.classList.add('active');\n    if (bList) bList.classList.remove('active');\n  }\n  localStorage.setItem('kb-view', m);\n}\ndocument.addEventListener('DOMContentLoaded', () => {\n  const s = localStorage.getItem('kb-view') || 'grid';\n  setViewMode(s);\n});\n\ndocument.addEventListener('DOMContentLoaded', () => {\n  document.querySelectorAll('pre').forEach(pre => {\n    const b = document.createElement('button');\n    b.className = 'copy-code-btn';\n    b.innerText = 'Copy';\n    b.onclick = () => {\n      const c = pre.querySelector('code') ? pre.querySelector('code').innerText : pre.innerText;\n      navigator.clipboard.writeText(c).then(() => {\n        b.innerText = 'Copied!';\n        setTimeout(() => { b.innerText = 'Copy'; }, 2000);\n      });\n    };\n    pre.appendChild(b);\n  });\n});\n\nwindow.addEventListener('keydown', (e) => {\n  if ((e.key === '/' || (e.metaKey && e.key === 'k')) && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {\n    e.preventDefault();\n    const q = document.getElementById('global-search-input');\n    if (q) q.focus();\n  }\n});\n\n// Scrollspy for TOC\nwindow.addEventListener('scroll', () => {\n  const headers = document.querySelectorAll('.article-body h1, .article-body h2, .article-body h3');\n  const scrollPos = window.scrollY + 100;\n  headers.forEach(h => {\n    if (h.offsetTop <= scrollPos) {\n      const id = h.getAttribute('id');\n      if (id) {\n        document.querySelectorAll('.reading-sidebar a').forEach(a => {\n          a.classList.toggle('active', a.getAttribute('href') === '#' + id);\n        });\n      }\n    }\n  });\n});\n\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n  if (window.renderMathInElement) {\n    renderMathInElement(document.body, {\n      delimiters: [\n        {left: '$$', right: '$$', display: true},\n        {left: '$', right: '$', display: false},\n      ],\n      throwOnError : false\n    });\n  }\n});\n</script>\n\n</body>\n</html>\n"