"<!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:2412.03342v3 [cs.CV] 10 Mar 2025\n\nUniVAD: A Training-free Unified Model for Few-shot Visual Anomaly Detection\nZhaopeng Gu1,2 Bingke Zhu1,3 Guibo Zhu1,2\nYingying Chen1,3 Ming Tang1,2 Jinqiao Wang1,2,3\n1\nFoundation Model Research Center, Institute of Automation,\nChinese Academy of Sciences, Beijing, China\n2\nUniversity of Chinese Academy of Sciences, Beijing, China\n3\nObjecteye Inc., Beijing, China\nguzhaopeng2023@ia.ac.cn\n{bingke.zhu,gbzhu,yingying.chen,tangm,jqwang}@nlpr.ia.ac.cn\n\nhttps://uni-vad.github.io\n\nAbstract\nVisual Anomaly Detection (VAD) aims to identify abnormal\nsamples in images that deviate from normal patterns, covering multiple domains, including industrial, logical, and\nmedical fields. Due to the domain gaps between these fields,\nexisting VAD methods are typically tailored to each domain, with specialized detection techniques and model architectures that are difficult to generalize across different\ndomains. Moreover, even within the same domain, current\nVAD approaches often follow a “one-category-one-model”\nparadigm, requiring large amounts of normal samples to\ntrain class-specific models, resulting in poor generalizability and hindering unified evaluation across domains. To address this issue, we propose a generalized few-shot VAD\nmethod, UniVAD, capable of detecting anomalies across\nvarious domains, such as industrial, logical, and medical anomalies, with a training-free unified model. UniVAD only needs few normal samples as references during testing to detect anomalies in previously unseen objects, without training on the specific domain. Specifically,\nUniVAD employs a Contextual Component Clustering (C3 )\nmodule based on clustering and vision foundation models\nto segment components within the image accurately, and\nleverages Component-Aware Patch Matching (CAPM) and\nGraph-Enhanced Component Modeling (GECM) modules\nto detect anomalies at different semantic levels, which are\naggregated to produce the final detection result. We conduct experiments on nine datasets spanning industrial, logical, and medical fields, and the results demonstrate that\nUniVAD achieves state-of-the-art performance in few-shot\nanomaly detection tasks across multiple domains, outperforming domain-specific anomaly detection models. Code\nis available at https://github.com/FantasticGNU/UniVAD.\n\nMVTec LOCO\n(Logical)\n\nBrainMRI\n(Medical)\n\n68.0\n\n75.0\n\n52.5\n\nLiverCT\n(Medical)\n68.0\n\n61.0\n\n41.2\n54.0\n\nRESC\n(Medical)\n\n83.0\n\n82.5\n\n54.5\n\n75.0\n67.5\n\n47.0\n65.0\n\n75.0\n\n85.0\n\n95.0\n\nMVTec-AD\n(Industrial)\n\n65.8\n\n71.5\n\n51.2\n57.5\n63.8\n70.0\n\nHIS\n(Medical)\n\n90.0\n\n59.0\n\nN/A\n77.2\n\nVisA\n(Industrial)\n\n63.5\n\n63.8\n\n57.5\n55.0\n60.0\n65.0\n70.0\n\nChestXray\n(Medical)\n\n65.0\n72.5\n80.0\n\nOCT17\n(Medical)\nAnomalyGPT\nWinClip\nComAD\nMedClip\nUniVAD (ours)\n\nFigure 1. 1-shot performance of existing VAD methods and\nUniVAD across different datasets in various domains. UniVAD\nachieves state-of-the-art results across multiple datasets and domains, outperforming specialized methods in each domain.\n\n1. Introduction\nVisual Anomaly Detection (VAD) [11, 19, 29, 36] is a critical task that seeks to identify abnormal samples in images\nthat deviate from established normal patterns, leveraging\ncomputer vision techniques [13, 27]. Such anomalies are\nrare occurrences but signify critical conditions, including\nerrors, defects, or lesions, that necessitate timely intervention for further analysis. VAD spans multiple fields and\n1\n\n\fhas applications across diverse industries, such as industrial anomaly detection [11, 19, 29], logical anomaly detection [14, 21, 25], and medical anomaly detection [2, 16].\nHowever, significant variations in data distributions and\nanomaly types across domains result in current VAD methods [2, 25, 29] being highly specialized for specific domains, often employing custom detection algorithms and\nmodel architectures. Consequently, methods optimized for\none domain tend to perform poorly in others. For instance, one of the state-of-the-art industrial anomaly detection methods, PatchCore [29], achieves a 1-shot imagelevel AUC of 84.1% on the industrial dataset MVTecAD [4]. However, its performance drops significantly to\n62.0% when applied to the MVTec LOCO [5] dataset for\nlogical anomaly detection. Furthermore, even within the\nsame domain, most contemporary VAD approaches adopt\na “one-category-one-model” paradigm, where a separate\nmodel is trained for each object category. Once trained,\neach model is limited to the specific object category. This\ndomain- and category-specific approach constrains VAD research’s standardization and scalability.\nTo address these limitations, we propose a training-free\ngeneralized anomaly detection method, UniVAD, which\nleverages a unified model to detect anomalies across multiple domains. UniVAD can handle industrial, logical, medical, and other anomalies without requiring domain-specific\ndata training. Instead, UniVAD requires only a few normal\nsamples of the target category during the testing phase to\nperform anomaly detection. This approach significantly enhances the generalizability and transferability of anomaly\ndetection models, as illustrated in Figure 1.\nSpecifically, UniVAD utilizes a contextual component\nclustering module, incorporating clustering techniques [25]\nand visual foundation models [17, 22, 24] to segment components within an image. Following this, UniVAD applies\na component-aware patch-matching module and a graphenhanced component modeling module to detect anomalies\nat various semantic levels. The component-aware patchmatching module identifies anomalies such as structural\ndefects or tissue lesions by matching patch-level features\nwithin each component. Meanwhile, the graph-enhanced\ncomponent modeling module employs graph-based component feature aggregation to model relationships between image components, facilitating the detection of more complex\nlogical anomalies, such as missing, added, or incorrect components, through inter-component feature matching.\nOur experiments, conducted across nine datasets covering industrial, logical, and medical domains, such as\nMVTec-AD [4], VisA [38], MVTec LOCO [5], Brain\nMRI [1], and Liver CT [6, 23], demonstrate that UniVAD\nachieves state-of-the-art performance in few-shot anomaly\ndetection across multiple domains, significantly outperforming domain-specific models.\n\nIndustrial AD\n\npre-train\ntest\n\nIndustrial\nAD Model\n\nMVTec-AD\n\nNatural Images\n\npre-train\n\nLogical AD\n\nUniVAD\ntest\n\npre-train\nLogical\nAD Model\n\nUnseen Domains:\n\ntest\nIndustrial\nAD\n\nMVTec LOCO\n\nMedical AD\nLogical\nAD\n\ntest\n\npre-train\nMedical\nAD Model\n\nMedical\nAD\n\nBrainMRI\n\n(a) One-domain-one-method\n\n(b) One-for-all model\n\nFigure 2. Comparison between UniVAD and existing VAD methods. Existing VAD methods are specifically designed for each\ndomain, whereas UniVAD can perform anomaly detection tasks\nacross multiple domains using a unified model.\n\nOur contributions are listed as follows:\n• We introduce the first training-free unified few-shot visual\nanomaly detection method capable of detecting anomalies across industrial, logical, and medical domains. This\nunified approach reduces the significant workload to develop separate detection methods and model architectures\nfor each domain, thereby promoting the standardization\nof anomaly detection research.\n• We design a contextual component clustering module\nthat effectively segments object components under fewshot learning conditions. Additionally, combined with\nour component-aware patch matching module and graphenhanced component modeling module, UniVAD reliably\ndetects anomalies across different semantic levels.\n• Comprehensive experiments on nine datasets spanning\nindustrial, logical, and medical domains demonstrate\nthat UniVAD achieves state-of-the-art performance in\nfew-shot anomaly detection, establishing its effectiveness\nand generalizability across domains.\n\n2. Related Work\n2.1. Visual Anomaly Detection\nIn traditional visual anomaly detection, methods are tailored\nto specific domains to accommodate distinct data characteristics. Industrial anomaly detection focuses on identifying defects, which are generally small and localized,\nprompting recent methods to emphasize local image features. Practical approaches include patch feature matching, where patch features of test samples are compared to\nthose of normal samples to compute anomaly scores [8, 29],\n2\n\n\f3. Method\n\nand reconstruction-based methods that leverage networks\ntrained on normal samples to identify anomalies through\nreconstruction loss [18, 36]. Additionally, other approaches\nemploy pre-trained models, such as CLIP [27], to evaluate patch features against textual descriptions of “normal”\nand “anomalous” states, facilitating a versatile approach to\nanomaly detection [10, 19].\nLogical anomaly detection [5] assesses whether an image adheres to logical constraints, such as correct components, colors, or quantities, requiring a higher level of semantic understanding. Logical anomalies typically result\nfrom incorrect combinations of normal elements. Methods\nin this area often involve segmenting components [14, 25,\n26] to evaluate individual features such as color, area, and\nquantity, thereby ensuring logical coherence.\nMedical anomaly detection aims to locate pathological\nregions in medical images. Approaches in this domain include GAN-based [12], reconstruction-based [7], and selfsupervised learning methods [31]. However, variability\nacross different body parts and diseases continues to pose\nsubstantial challenges for generalizability.\nRecent efforts aim to develop unified models for\nanomaly detection. For example, UniAD [36] employs a\npatch feature reconstruction method optimized for industrial applications; however, its performance decreases in\nother domains and requires large volumes of normal data\nsamples for model training.\nIn contrast, UniVAD operates across domains using a\ntraining-free unified model and requires only a few normal samples for reference during testing, as shown in Figure 2. This approach eliminates the need for prior training\non domain-specific data, offering greater flexibility across\nvarious anomaly detection tasks.\n\n3.1. Overall Architecture\nGiven a query image Iq ∈ RH×W ×3 and K reference normal images In ∈ RK×H×W ×3 , UniVAD first employs a\ncontextual component clustering module to segment components within both the query and reference images, producing corresponding component masks. UniVAD then utilizes an image encoder pre-trained on large-scale datasets\nto extract features from the query and normal images, resulting in a feature map Fq ∈ RH1 ×W1 ×C for the query\nimage and Fn ∈ RK×H1 ×W1 ×C for the normal images.\nBy applying group average pooling based on the component\nmasks, UniVAD obtains component-level features for both\nthe query and normal images, denoted as Fqc ∈ RNq ×C\nfor the query image and Fnc ∈ RK×Nn ×C for the normal\nimages, where Nq and Nn represent the number of components in the query and normal images, respectively.\nThe feature maps Fq and Fn are subsequently passed\nthrough interpolation to obtain patch-level features, Pq ∈\nRH2 ×W2 ×C and Pn ∈ RK×H2 ×W2 ×C . In parallel, textual\ndescriptions of normal and anomalous semantics are processed by a text encoder, yielding textual features Tn ∈ RC\nfor normal semantics and Ta ∈ RC for anomalous semantics. The patch-level features Pq , Pn , and textual features\nTn and Ta are then input into the component-aware patchmatching module to generate a structural anomaly map.\nAt the same time, the component features of query image and normal images, Fqc and Fnc , are passed through the\ngraph-enhanced component modeling module to produce a\nlogical anomaly map. Finally, UniVAD combines the structural and logical anomaly maps to generate the final unified\nanomaly detection result, as shown in Figure 3.\nIn Sec 3.2 to 3.4, we provide a detailed description of\ncontextual component clustering, component-aware patch\nmatching, and graph-enhanced component modeling. Additionally, we provide pseudo-code descriptions of these modules in Appendix A.\n\n2.2. Component Segmentation\nLogical anomaly detection frequently relies on component\nsegmentation to extract sub-parts of an image and evaluate\neach for anomalies. ComAD [25] introduces this approach\nby using clustering for segmentation; however, clustering\nrequires many samples, limiting its applicability in few-shot\nscenarios. More recent methods, such as CSAD [14] and\nSAM-LAD [26], leverage vision models like SAM [22] but\nface challenges with segmentation granularity, often producing outputs that are either overly fine or too coarse.\nPSAD [21] addresses this issue by employing a limited set\nof annotated samples, which increases training costs and requires manual labeling.\nUniVAD combines clustering with vision foundation\nmodels, utilizing vision foundation models to produce initial component masks and refining segmentation granularity\nthrough clustering. This approach allows for precise segmentation in few-shot settings, enhancing the model’s ability to perform effectively with minimal data.\n\n3.2. Contextual Component Clustering\nTo achieve accurate component segmentation with limited\nnormal samples, we propose the Contextual Component\nClustering (C3 ) module, which combines visual foundation\nmodels with clustering techniques to enable precise component segmentation in few-shot setting.\nUpon receiving an input image, the C3 module first\nuses the Recognize Anything Model [37] to identify objects\nand generate content tags. Next, the Grounded SAM [28]\nmethod generates masks for all detected elements. However, SAM [22] often faces challenges with segmentation\ngranularity, producing masks that are either too fine or too\ncoarse, which can be inconsistent across normal and query\nimages. To address this, we refine and filter SAM’s output.\n3\n\n\fPart 2: Component-Aware Patch Matching\nNormal Texts\nAbnormal Texts\n\nText\nEncoder\n\nUnified Inputs\n\nTn Ta\n\nCosine Similarity\n……\n\nIndustrial Inputs\n\nLogical Inputs\n\nQuery Patches\n\nMedical Inputs\n\nNN\nPart 1: Contextual Component Clustering\n\nQuery Image\n\nQuery\nComponents\n\nStructural\nAnomaly Map\n\nImage\nEncoder\n\nNormal Component Patches\n\nPart 3: Graph-Enhanced Component Modeling\n\nVAD Result\nComponent Feature\nAggregator\n\nNormal\nComponents\n\nNormal Images\n\nFrozen Modules\n\nNN\n\nPatch\nFeatures\nNormal Patches\n\nContextual\nComponent\nClustering\n\nQuery Component Patches\n\nQuery Component\nFeatures\n\nNN\n\nComponent\nFeatures\n\nLogical\nAnomaly Map\n\nNN: Nearest Neighbor Search\nNormal Component\nFeatures\n\nTn &amp; Ta ： Normal and Abnormal Text Features\n\nFigure 3. The overall architecture of UniVAD. Given an input image, UniVAD first generates masks for each entity using the Contextual\nComponent Clustering module (Sec 3.2). UniVAD then applies the Component-Aware Patch Matching module (Sec 3.3) and the GraphEnhanced Component Modeling module (Sec 3.4) to detect structural and logical anomalies. The outputs from both expert modules are\ncombined to produce the final unified anomaly detection result.\n\nas shown in Figure 4. Specifically, we first extract the feature map of the normal images Fn ∈ RK×H1 ×W1 ×C using a pre-trained image encoder. Then, we apply the Kmeans clustering algorithm to the features in Fn , clustering them into N groups and yielding N cluster centroids\nC ∈ RN ×C . For each feature in the feature maps of both\nnormal and query images, we compute its similarity to each\ncluster centroid, thereby generating N cluster masks for the\nimage, denoted as Mcluster ∈ RN ×H1 ×W1 . After that, we filter the background masks by evaluating whether the values\nat the four corners of each mask are non-zero. This process\nyields N ′ valid masks, which are then resized to the original\n′\nimage dimensions to produce Mvalid ∈ RN ×H×W .\ni\nNext, for each mask Msam\nin Msam , we compute the Ini\ntersection over Union (IoU) between Msam\nand each mask\nj\nin Mvalid , identifying the mask Mvalid with the highest IoU.\ni\nWe then assign the label j to Msam\n:\n\nGrounded\nSAM\nFiltering\nImage\nEncoder\nImage Input\n\nClustering\n\nComponent Mask\n\nFigure 4. Architecture of the C3 module.\n\nSpecifically, after obtaining M initial component masks\nfrom Grounded SAM, represented as Msam ∈ RM ×H×W ,\nthe C3 module evaluates the masks based on their quantity\nand area coverage. If only one mask is generated and it\ncovers nearly the entire image (exceeding γ% of the area),\nwe infer that the image represents a textured surface (e.g.,\nwood), and treat the entire image as a single component,\noutputting a mask covering the full image: M = 1H×W .\nIf Grounded SAM generates a single mask that covers\nless than γ% of the image area, we speculate that the image contains a single object, and we directly use the SAMproduced mask as the final mask: M = Msam .\nIn cases where Grounded SAM produces multiple\nmasks, indicating the presence of multiple objects, we refine the SAM-generated masks using a clustering approach,\n\nj\ni\ni\nLabel(Msam\n) = arg max IoU(Msam\n, Mvalid\n).\n\n(1)\n\nj\n\nFinally, for each j (1 ≤ j ≤ N ′ ), the C3 module replaces\nj\nwith the union of the masks in Msam\nthe original mask Mvalid\nthat are assigned the label j, resulting in the final mask set\n′\nM ∈ RN ×H×W :\n[\ni\nMj =\nMsam\n.\n(2)\ni )=j\nLabel(Msam\n\n4\n\n\fThis approach combines the precise segmentation capabilities of visual foundation models with the granularity\ncontrol provided by clustering methods, enabling accurate\ncomponent segmentation in few-shot settings.\nUpon completing component segmentation, UniVAD\nproceeds to detect structural and logical anomalies in the\nimage using the component-aware patch-matching module\nand the graph-enhanced component modeling module.\n\nSpecifically, we extract normal and anomalous text features,\nTn and Ta , using a pretrained text encoder that encodes the\ntextual descriptions of normal and anomalous states. We\nthen compute the cosine similarity between each patch feature of the query image and Tn and Ta , obtaining the imagetext anomaly score for each patch:\n\n3.3. Component-Aware Patch Matching\n\nwhere sim(·, ·) represents the cosine similarity calculation.\nFinally, we sum the three anomaly scores for each patch\nto derive the structural anomaly score map:\n\nj\nj\nScorevl (Pqi\n) = softmax(sim(Pqi\n, [Tn , Ta ])),\n\nOur Component-Aware Patch Matching (CAPM) method\nbuilds on patch feature matching, extending it by incorporating component constraints and image-text feature similarity comparisons to improve performance.\nIn the patch feature matching process, we first employ\na network pretrained on large-scale datasets, such as ImageNet [30], as an image encoder to extract the feature map\nof the query image, Fq ∈ RH1 ×W1 ×C , and the feature map\nof the normal images, Fn ∈ RK×H1 ×W1 ×C . Next, both Fq\nand Fn are processed through interpolation to obtain patch\nfeatures Pq ∈ RH2 ×W2 ×C and Pn ∈ RK×H2 ×W2 ×C , respectively. For each patch in the query image, we compute\nthe cosine distance between Pqi and all patch features in Pn ,\nusing the minimum cosine distance as the patch-matching\nanomaly score for Pqi , as shown in Eq. (3):\nScorepm (Pqi ) = min(distance(Pqi , Pn )).\n\nScorestru = α Scorepm + β Scoreaware + γ Scorevl , (7)\nwhere α, β and γ are hyperparameters, which are all set to\n1/3 in our experiments.\n\n3.4. Graph-Enhanced Component Modeling\nThe CAPM module introduced earlier is primarily designed\nto detect structural anomalies with low-level semantics,\nwhere the anomalous content has never appeared in the normal samples. However, for higher-level semantic logical\nanomalies, the image content may exist in the normal samples but is combined incorrectly. Such anomalies are challenging to detect through patch feature matching alone, as\nthey require a higher level of semantic understanding.\nTo address this problem, we design a Graph-Enhanced\nComponent Modeling (GECM) module, which focuses on\nthe holistic characteristics of each component, enabling it\nto detect the addition, omission, or misplacement of components. Specifically, after obtaining the component masks,\nthe GECM module first employs a pretrained feature extractor to generate the feature map Fq ∈ RH1 ×W1 ×C for\nthe query image and Fn ∈ RK×H1 ×W1 ×C for the normal\nimages. We then apply group average pooling to capture the\ndeep features of each component from the query and normal\nsamples, denoted as Fqc ∈ RNq ×C and Fnc ∈ RK×Nn ×C .\nNext, we employ a Component Feature Aggregator (CFA) module to further model each component’s features. In the Component Feature Aggregator, we initially\nmodel each component feature as a node in a graph, and the\ncosine similarity between any two component features as\nthe weight of the edge connecting these nodes, allowing us\nto compute the adjacency matrix for all nodes in the graph:\n\n(3)\n\nHowever, the standard patch feature matching method\nencounters limitations, such as its inability to distinguish\nbetween foreground and background regions, which may\nlead to false positives in background areas, and its failure\nto differentiate between different object components, which\ncan mistakenly pair patches from other irrelevant regions\nwith similar color or texture, resulting in missed detections.\nTo address these issues, we leverage the component mask\nobtained from the C 3 module to perform feature matching\nwithin each component, effectively enhancing the accuracy\nof anomaly detection.\nSpecifically, after obtaining the patch features Pn of normal samples, we use the N ′ component masks derived from\nthe C 3 module to create N ′ patch subsets Pni (1 ≤ i ≤\nN ′ ), where patches within each mask are allocated to their\nrespective subsets:\nPni = {Pnj | Mij = 1}.\n\n(4)\n\nWe apply the same process to Pq to obtain Pqi , and perform patch feature matching within each subset to calculate\nthe component-aware anomaly score for each patch:\nj\nj\nScoreaware (Pqi\n) = min(distance(Pqi\n, Pni )).\n\n(6)\n\n\n\n(5)\n\nAdditionally, we employ an image-text feature-matching\napproach to calculate an anomaly score for each patch.\n\nS11\n S21\n\nA= .\n ..\n\nS12\nS22\n..\n.\n\n···\n···\n..\n.\n\n\nS1N\nS2N \n\n..  ,\n. \n\nSN 1\n\nSN 2\n\n···\n\nSN N\n\n(8)\n\nwhere N denotes the number of components (Nq for the\nquery image and Nn for normal images), and Sij represents\n5\n\n\fTable 1. Comparison between UniVAD and existing methods under the 1-normal-shot setting, where image-level AUC and pixel-level\nAUC are used to evaluate the performance of image-level anomaly detection and pixel-level anomaly localization, respectively. The best\nresults are highlighted in bold.\nTask\n\nDataset\n\nPatchCore\n\nAnomalyGPT\n\nWINCLIP\n\nComAD\n\nUniAD\n\nMedCLIP\n\nUniVAD (ours)\n\nImage-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\nHIS\nChestXray\nOCT17\n\n84.0\n74.8\n62.0\n73.2\n44.9\n56.3\n55.6\n66.4\n59.9\n\n94.1\n87.4\n60.4\n73.1\n60.3\n82.4\n50.2\n68.5\n77.5\n\n93.1\n83.8\n58.0\n55.4\n60.3\n72.9\n55.8\n70.2\n79.7\n\n57.3\n53.9\n62.2\n33.3\n45.0\n73.5\n49.8\n50.1\n57.6\n\n70.3\n61.3\n50.9\n50.0\n35.0\n53.5\n50.0\n60.6\n44.4\n\n75.2\n69.0\n54.9\n69.7\n40.5\n66.9\n71.1\n71.4\n64.6\n\n97.8\n93.5\n71.0\n80.2\n70.0\n85.5\n72.6\n72.2\n82.1\n\nPixel-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n89.9\n93.4\n69.8\n96.0\n95.6\n78.2\n\n95.3\n96.2\n70.3\n96.0\n95.8\n94.0\n\n95.2\n96.2\n58.8\n86.6\n94.5\n87.9\n\n-\n\n90.7\n90.3\n70.6\n93.6\n88.5\n80.7\n\n79.1\n88.2\n69.1\n91.7\n93.8\n91.5\n\n96.5\n98.2\n75.1\n96.8\n96.3\n94.9\n\nthe normalized similarity between nodes i and j, defined as:\n′\nSij\nSij = PN\n\n′\nk=1 Sik\n\n′\n, Sij\n= sim(nodei , nodej ).\n\nwhere ϕ and ψ are hyperparameters, and they are set to 0.5\nin our experiments.\nBy combining Scorestru and Scorelogic , we derive the final\nanomaly score map:\n\n(9)\n\nScorefinal = δ Scorestru + η Scorelogic ,\n\nSubsequently, we leverage the adjacency matrix A to aggregate node information again via a graph attention operation, resulting in feature embeddings that more comprehensively represent the overall characteristics of each component. Specifically, these embeddings are expressed as\nEq = G(Aq , Fqc ) and En = G(An , Fnc ), where G represents the graph attention operation [34].\nFor each component feature embeddings Eqi in Eq , we\ncompute its minimum cosine distance to the vectors in En ,\nwhich serves as the deep anomaly score for that component:\nScoredeep (Eqi ) = min(distance(Eqi , En )).\n\nwhere δ and η are set to 0.5 by default.\n\n4. Experiments\n4.1. Experimental Setups\nDatasets. We conduct extensive experiments on nine\ndatasets spanning industrial, logical, and medical anomaly\ndetection domains. For industrial anomaly detection, we\nuse the widely recognized MVTec-AD [4] and VisA [38]\ndatasets. For logical anomaly detection, we focus on the\ncomprehensive MVTec LOCO [5] dataset. In the medical anomaly detection domain, following the recent BMAD\nbenchmark, we select six datasets: BrainMRI [1], liverCT [6, 23], RetinalOCT [15], ChestXray [32], HIS [3],\nand OCT17 [20]. Since ChestXray [32], HIS [3], and\nOCT17 [20] datasets do not provide pixel-level anomaly annotations, we evaluate only image-level anomaly detection\nperformance on these three datasets. A detailed description\nof the nine datasets is provided in Appendix B.\nCompeting Methods and Baselines. In this study, we\ncompare the performance of UniVAD with state-of-the-art\nmethods from various domains, under two different settings, few-normal-shot and few-abnormal-shot. In the fewnormal-shot setting, the model is not trained on the target\ndataset; instead, a few normal samples are provided only\nas reference during testing. Under this setting, we selected\n\n(10)\n\nIn addition to deep features, geometric features such as\ncomponent area, color, and position are also effective for\ndetecting logical anomalies. Therefore, we compute these\ngeometric features for each component in both query and\nnormal samples, combining them into geometric feature\nvectors, represented as Gq ∈ RNq ×Cg and Gn ∈ RNn ×Cg ,\nand utilize the following formula to calculate the geometric\nanomaly score:\nScoregeo (Giq ) = min(distance(Giq , Gn )).\n\n(11)\n\nThen, we combine Scoredeep and Scoregeo to obtain the\nlogical anomaly score:\nScorelogic = ϕ Scoredeep + ψ Scoregeo .\n\n(13)\n\n(12)\n6\n\n\fTable 3. Comparison of different implementations of the C 3 module across multiple datasets. G-SAM Only in table refers to the use\nof visual foundation models exclusively. The best performance results are highlighted in bold.\n\nTable 2. Comparison between UniVAD and existing methods\nunder the 4-abnormal-shot setting, where image-level AUC and\npixel-level AUC are used to evaluate the performance of imagelevel anomaly detection and pixel-level anomaly localization, respectively. The experimental results in the table are cited from\nMVFA [16], and the best results are highlighted in bold.\nTask\n\nDataset\n\nDRA\n\nBGAD\n\nMVFA\n\nUniVAD\n\nImg-level\n(AUC)\n\nBrainMRI\nLiverCT\nRESC\nHIS\nChestXray\nOCT\n\n80.6\n59.6\n90.9\n68.7\n75.8\n99.0\n\n83.6\n72.5\n86.2\n-\n\n92.4\n81.2\n96.2\n82.7\n82.0\n99.4\n\n94.1\n87.5\n97.3\n85.7\n82.4\n99.7\n\nBrainMRI\nLiverCT\nRESC\n\n74.8\n71.8\n77.3\n\n92.7\n98.9\n93.8\n\n97.3\n99.7\n99.0\n\n98.6\n99.7\n99.0\n\nPx-level\n(AUC)\n\nDataset\n\nCluster Only\n\nG-SAM Only\n\nC 3 Module\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n(97.3, 96.1)\n(92.5, 98.0)\n(67.5, 70.9)\n(73.9, 96.7)\n(63.6, 96.1)\n(84.2, 94.9)\n\n(97.5, 96.1)\n(92.1, 97.7)\n(67.8, 74.9)\n(74.5, 94.9)\n(63.7, 96.3)\n(85.0, 94.6)\n\n(97.8, 96.5)\n(93.5, 98.0)\n(71.0, 75.1)\n(80.2, 96.8)\n(70.0, 96.3)\n(85.5, 94.9)\n\nTable 4. Comparison of the clustering part in the C 3 module using\nimage features extracted by different image encoders.\n\nPatchCore [29], WinCLIP [19], AnomalyGPT [11], and\nUniAD [36] for industrial anomaly detection, ComAD [25]\nfor logical anomaly detection, and MedCLIP [33] for medical anomaly detection. Few-abnormal-shot is a commonly\nused setting in medical anomaly detection, where testing is\nperformed after training on a small number of normal and\nabnormal samples from the target dataset. To demonstrate\nthe generality of UniVAD, we also compared it with existing methods in the few-abnormal-shot setting, selecting\nDRA [9], BGAD [35], and MVFA [16] under this setting.\nEvaluation Protocols. In alignment with established\nanomaly detection methodologies, we evaluate performance\nusing the Area Under the Receiver Operating Characteristic\nCurve (AUC). Image-level AUC is used to assess anomaly\ndetection performance, while pixel-level AUC is employed\nto evaluate anomaly localization performance.\nImplementation Details. In few-normal-shot setting, we\ndo not conduct any further training on anomaly detection\ndatasets for UniVAD. We resize all images to a resolution\nof 448x448 pixels, and utilize two widely used vision encoders, CLIP-L/14@336px and DINOv2-G/14, as our image encoders, with their parameters frozen. For image-level\nanomaly scores, it is common to derive results from pixellevel outputs using a post-processing method. Depending\non the distribution of detection data, popular approaches include using either the maximum or the mean of pixel-level\nresults. In UniVAD, for datasets like HIS [3], where abnormal samples (e.g., cancer cell-stained slides) exhibit global\ndifferences compared to normal samples, we use the mean\nof the pixel-level results as the image-level anomaly score.\nFor industrial anomaly detection, logical anomaly detection, and the remaining medical anomaly detection datasets,\nwhere abnormal regions occupy only a small portion of the\nimage and the rest remains normal, we use the maximum of\npixel-level results as the global anomaly score.\n\nDataset\n\nCLIP-ViT\n\nDINO\n\nDINOv2\n\nMVTec-AD\nVisA\nMVTec LOCO\nRESC\n\n(97.7, 96.5)\n(93.5, 98.0)\n(71.1, 74.5)\n(85.2, 94.6)\n\n(97.8, 96.5)\n(93.5, 98.0)\n(71.0, 75.1)\n(85.5, 94.9)\n\n(97.9, 96.4)\n(93.2, 98.0)\n(70.9, 74.6)\n(85.2, 94.8)\n\n4.2. Main Results\nFew-normal-shot Setting. We conduct experiments using\nthe same few-normal-shot setting as most existing few-shot\nanomaly detection methods [11, 19, 29], where the model\nis tested on objects it has never encountered during training, with a small number of normal samples provided as\nreferences during testing. Table 1 presents a comparison of\nthe performance of UniVAD and various domain-specific\nanomaly detection methods under the 1-normal-shot setting. It can be observed that UniVAD significantly outperforms existing domain-specific methods in both image-level\nand pixel-level results across different domains. Compared\nto state-of-the-art methods in each domain, our approach\nachieves an average improvement of 6.2% in image-level\nAUC and 1.7% in pixel-level AUC. The experimental results demonstrate the strong transferability of UniVAD.\nFew-abnormal-shot Setting. One of the key features of\nUniVAD is its robust generalization capability. Without requiring any training on domain-specific anomaly detection\ndatasets, UniVAD demonstrates outstanding cross-domain\nanomaly detection performance by using only a minimal\nnumber of normal samples as a reference during the testing\nphase. On the other hand, for scenarios demanding highprecision detection on specific domain data, we provide a\ndomain adaptation training method. This method allows\nUniVAD to be fine-tuned on domain-specific datasets to\nachieve optimal performance for particular tasks. Such finetuning requires only a small number of normal and anomalous samples from the target dataset, which is referred to\nas the few-abnormal-shot setting. Several popular medi7\n\n\fTable 5. Comparison between Patch Matching and CAPM methods on MVTec-AD, VisA, MVTec LOCO and BrainMRI datasets.\nImg-AUC and Px-AUC in table represent image-level AUC and\npixel-level AUC. The best performance results are in bold.\nDataset\n\nPatch Matching\nImg-AUC\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\n\n96.9\n91.8\n62.0\n79.1\n\nPx-AUC\n96.3\n97.8\n69.8\n96.4\n\nTable 6. Comparison on the MVTec LOCO dataset under different settings. Geo feat. represent components geometric features,\nDeep feat. represents component deep features, and CFA represents component feature aggregator. The best performance results\nare highlighted in bold.\n\nCAPM\nImg-AUC\n97.8\n93.4\n64.1\n80.2\n\nModules in GECM\n\nPx-AUC\n\nGeo feat.\n\n96.5\n98.2\n70.2\n96.8\n\n✓\n✓\n✓\n\ncal anomaly detection methods [9, 16, 35] employ the fewabnormal-shot setting for experimentation. We apply the\nsame approach to UniVAD and present a comparison of its\nperformance with these methods under the 4-abnormal-shot\nsetting across six medical datasets in Table 2. Experimental\nresults indicate that, under the few-abnormal-shot setting,\nUniVAD also outperforms existing approaches. Implementation details about UniVAD in the few-abnromal-shot setting can be found in Appendix C.\n\nDeep feat.\n\n✓\n✓\n\nMVTec LOCO\nCFA\n\nImage-AUC\n\nPixel-AUC\n\n✓\n\n64.1\n66.6\n69.4\n71.0\n\n70.2\n73.2\n74.8\n75.1\n\nNormal\nImage\n\nQuery\nImage\n\nVAD\nResult\n\n4.3. Ablation Study\n\nGround\nTruth\n\nWe conduct extensive ablation studies on our proposed\nmodules to demonstrate their effectiveness. Here, we primarily present the ablation results of our core module, with\nadditional ablation study results provided in Appendix D.\nContextual Component Clustering. Contextual Component Clustering (C 3 ) module id build upon visual foundation models such as RAM [37], Grounding DINO [24], and\nSAM [22], as well as clustering techniques. It addresses the\nchallenges of poor performance in few-shot settings commonly encountered in clustering methods and the difficulty\nof controlling segmentation granularity in SAM [22]. In\nTable 3, we present a comparative analysis of performance\nresults using only visual foundation models, only clustering\nmethods, and the C 3 module, demonstrating the effectiveness of the C 3 module. We also provide a comparison of\ndifferent image encoders utilized in clustering in Table 4.\nThe performance differences are minimal, demonstrating\nthe robustness of the C 3 module across various encoders.\nComponent-Aware Patch Matching. The original patch\nfeature matching method matches all patch features from\nthe entire image, which can mistakenly pair patches from\nbackground or other irrelevant regions with similar color\nor texture, leading to decreased anomaly detection performance. In contrast, the CAPM module restricts the matching regions of patch features, ensuring that source and target patches originate from the same part. Table 5 compares\nthe performance of the original patch matching method and\nCAPM across multiple datasets, highlighting the effectiveness of CAPM in detecting structural anomalies.\n\nIndustrial AD\n\nLogical AD\n\nMedical AD\n\nFigure 5. Visualization result of UniVAD on datasets across diverse domains. UniVAD demonstrates a strong transferability by\naccurately segmenting previously unseen samples with only a single normal sample provided as reference.\n\nGraph-Enhanced Component Modeling. Patch features\nwith low-level semantics struggle to capture the overall\ncharacteristics of each component. Our GECM method,\nbuilt on a graph neural network, models the interaction between each component’s geometric and deep features, enhancing the detection performance for logical anomalies\nwith high-level semantics. Table 6 compares the performance differences from using only CAPM to incrementally\nadding each module in GECM, demonstrating GECM’s notable effectiveness in detecting logical anomalies.\n\n4.4. Visualization Results\nFigure 5 illustrates the visual anomaly detection results of\nUniVAD across various datasets in industrial anomaly detection, logic anomaly detection, and medical anomaly detection. With only a single normal sample as a reference,\nUniVAD accurately detects anomalies in previously unseen\nitems across diverse domains, demonstrating the method’s\nstrong transferability and practical applicability.\n8\n\n\f5. Limitation\n\n[5] Paul Bergmann, Kilian Batzner, Michael Fauser, David Sattlegger, and Carsten Steger. Beyond dents and scratches:\nLogical constraints in unsupervised anomaly detection and\nlocalization. International Journal of Computer Vision, 130\n(4):947–969, 2022. 2, 3, 6, 1\n[6] Patrick Bilic, Patrick Christ, Hongwei Bran Li, Eugene\nVorontsov, Avi Ben-Cohen, Georgios Kaissis, Adi Szeskin,\nColin Jacobs, Gabriel Efrain Humpire Mamani, Gabriel\nChartrand, et al. The liver tumor segmentation benchmark\n(lits). Medical Image Analysis, 84:102680, 2023. 2, 6\n[7] Yu Cai, Hao Chen, and Kwang-Ting Cheng. Rethinking autoencoders for medical anomaly detection from a theoretical\nperspective. In International Conference on Medical Image\nComputing and Computer-Assisted Intervention, pages 544–\n554. Springer, 2024. 3\n[8] Xuhai Chen, Yue Han, and Jiangning Zhang. April-gan:\nA zero-/few-shot anomaly classification and segmentation\nmethod for cvpr 2023 vand workshop challenge tracks 1&amp;2:\n1st place on zero-shot ad and 4th place on few-shot ad. arXiv\npreprint arXiv:2305.17382, 2023. 2\n[9] Choubo Ding, Guansong Pang, and Chunhua Shen. Catching\nboth gray and black swans: Open-set supervised anomaly\ndetection. In Proceedings of the IEEE/CVF conference on\ncomputer vision and pattern recognition, pages 7388–7398,\n2022. 7, 8\n[10] Zhaopeng Gu, Bingke Zhu, Guibo Zhu, Yingying Chen, Hao\nLi, Ming Tang, and Jinqiao Wang. Filo: Zero-shot anomaly\ndetection by fine-grained description and high-quality localization. arXiv preprint arXiv:2404.13671, 2024. 3\n[11] Zhaopeng Gu, Bingke Zhu, Guibo Zhu, Yingying Chen,\nMing Tang, and Jinqiao Wang. Anomalygpt: Detecting industrial anomalies using large vision-language models. In\nProceedings of the AAAI Conference on Artificial Intelligence, pages 1932–1940, 2024. 1, 2, 7\n[12] Changhee Han, Leonardo Rundo, Kohei Murao, Tomoyuki\nNoguchi, Yuki Shimahara, Zoltán Ádám Milacski, Saori\nKoshino, Evis Sala, Hideki Nakayama, and Shin’ichi Satoh.\nMadgan: Unsupervised medical anomaly detection gan using multiple adjacent brain mri slice reconstruction. BMC\nbioinformatics, 22:1–20, 2021. 3\n[13] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.\nDeep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern\nrecognition, pages 770–778, 2016. 1\n[14] Yu-Hsuan Hsieh and Shang-Hong Lai. Csad: Unsupervised component segmentation for logical anomaly detection. arXiv preprint arXiv:2408.15628, 2024. 2, 3\n[15] Junjie Hu, Yuanyuan Chen, and Zhang Yi. Automated segmentation of macular edema in oct using deep neural networks. Medical image analysis, 55:216–227, 2019. 6, 2\n[16] Chaoqin Huang, Aofan Jiang, Jinghao Feng, Ya Zhang, Xinchao Wang, and Yanfeng Wang. Adapting visual-language\nmodels for generalizable anomaly detection in medical images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11375–11385,\n2024. 2, 7, 8\n[17] Xinyu Huang, Yi-Jie Huang, Youcai Zhang, Weiwei Tian,\nRui Feng, Yuejie Zhang, Yanchun Xie, Yaqian Li, and Lei\n\nUniVAD currently relies on visual foundation models such\nas RAM [37], Grounding DINO [24], and SAM [22] for\ncomponent segmentation. The computational latency during inference somewhat limits its applicability in real-time\nscenarios. However, the key strength of UniVAD lies in\nits remarkable generalization capability. Even when provided with only a small number of normal samples as references, UniVAD is able to accurately detect anomalies across\ndiverse domains, thereby advancing the standardization of\nanomaly detection research.\n\n6. Conclusion\nIn this paper, we propose UniVAD, a novel, trainingfree, unified few-shot visual anomaly detection method\ncapable of detecting anomalies across various domains,\nincluding industrial, logical, and medical fields, using\na unified model. By leveraging a contextual component clustering module for precise segmentation, along\nwith component-aware patch matching and graph-enhanced\ncomponent modeling for multi-level anomaly detection,\nUniVAD achieves superior performance without the need\nfor domain-specific models or extensive training data. Experimental results across multiple datasets demonstrate that\nUniVAD outperforms existing domain-specific approaches,\noffering a more flexible and scalable solution for visual\nanomaly detection tasks and contributing to the standardization of research in the field of visual anomaly detection.\n\nReferences\n[1] Ujjwal Baid, Satyam Ghodasara, Suyash Mohan, Michel\nBilello, Evan Calabrese, Errol Colak, Keyvan Farahani,\nJayashree Kalpathy-Cramer, Felipe C Kitamura, Sarthak\nPati, et al. The rsna-asnr-miccai brats 2021 benchmark on\nbrain tumor segmentation and radiogenomic classification.\narXiv preprint arXiv:2107.02314, 2021. 2, 6, 1\n[2] Jinan Bao, Hanshi Sun, Hanqiu Deng, Yinsheng He, Zhaoxiang Zhang, and Xingyu Li. Bmad: Benchmarks for medical\nanomaly detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages\n4042–4053, 2024. 2, 1\n[3] Babak Ehteshami Bejnordi, Mitko Veta, Paul Johannes\nVan Diest, Bram Van Ginneken, Nico Karssemeijer, Geert\nLitjens, Jeroen AWM Van Der Laak, Meyke Hermsen,\nQuirine F Manson, Maschenka Balkenhol, et al. Diagnostic assessment of deep learning algorithms for detection of\nlymph node metastases in women with breast cancer. Jama,\n318(22):2199–2210, 2017. 6, 7, 2\n[4] Paul Bergmann, Michael Fauser, David Sattlegger, and\nCarsten Steger. Mvtec ad–a comprehensive real-world\ndataset for unsupervised anomaly detection. In Proceedings\nof the IEEE/CVF conference on computer vision and pattern\nrecognition, pages 9592–9600, 2019. 2, 6, 1\n\n9\n\n\fYan, et al. Grounded sam: Assembling open-world models\nfor diverse visual tasks. arXiv preprint arXiv:2401.14159,\n2024. 3\n[29] Karsten Roth, Latha Pemula, Joaquin Zepeda, Bernhard\nSchölkopf, Thomas Brox, and Peter Gehler. Towards total recall in industrial anomaly detection. In Proceedings\nof the IEEE/CVF conference on computer vision and pattern\nrecognition, pages 14318–14328, 2022. 1, 2, 7\n[30] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy,\nAditya Khosla, Michael Bernstein, Alexander C. Berg, and\nLi Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115\n(3):211–252, 2015. 5\n[31] Yu Tian, Fengbei Liu, Guansong Pang, Yuanhong Chen,\nYuyuan Liu, Johan W Verjans, Rajvinder Singh, and Gustavo\nCarneiro. Self-supervised pseudo multi-class pre-training for\nunsupervised anomaly detection and segmentation in medical images. Medical image analysis, 90:102930, 2023. 3\n[32] Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, and Ronald M Summers. Chestxray8: Hospital-scale chest x-ray database and benchmarks on\nweakly-supervised classification and localization of common\nthorax diseases. In Proceedings of the IEEE conference on\ncomputer vision and pattern recognition, pages 2097–2106,\n2017. 6, 2\n[33] Zifeng Wang, Zhenbang Wu, Dinesh Agarwal, and Jimeng\nSun. Medclip: Contrastive learning from unpaired medical\nimages and text. arXiv preprint arXiv:2210.10163, 2022. 7\n[34] Xin Xiang, Zenghui Wang, Jun Zhang, Yi Xia, Peng Chen,\nand Bing Wang. Agca: An adaptive graph channel attention\nmodule for steel surface defect detection. IEEE Transactions\non Instrumentation and Measurement, 72:1–12, 2023. 6\n[35] Xincheng Yao, Ruoqi Li, Jing Zhang, Jun Sun, and\nChongyang Zhang. Explicit boundary guided semi-pushpull contrastive learning for supervised anomaly detection.\nIn Proceedings of the IEEE/CVF Conference on Computer\nVision and Pattern Recognition, pages 24490–24499, 2023.\n7, 8\n[36] Zhiyuan You, Lei Cui, Yujun Shen, Kai Yang, Xin Lu,\nYu Zheng, and Xinyi Le. A unified model for multi-class\nanomaly detection. Advances in Neural Information Processing Systems, 35:4571–4584, 2022. 1, 3, 7\n[37] Youcai Zhang, Xinyu Huang, Jinyu Ma, Zhaoyang Li,\nZhaochuan Luo, Yanchun Xie, Yuzhuo Qin, Tong Luo,\nYaqian Li, Shilong Liu, et al. Recognize anything: A strong\nimage tagging model. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages\n1724–1732, 2024. 3, 8, 9\n[38] Yang Zou, Jongheon Jeong, Latha Pemula, Dongqing Zhang,\nand Onkar Dabeer. Spot-the-difference self-supervised pretraining for anomaly detection and segmentation. In European Conference on Computer Vision, pages 392–408.\nSpringer, 2022. 2, 6, 1\n\nZhang. Open-set image tagging with multi-grained text supervision. arXiv e-prints, pages arXiv–2310, 2023. 2\n[18] Jeeho Hyun, Sangyun Kim, Giyoung Jeon, Seung Hwan\nKim, Kyunghoon Bae, and Byung Jun Kang. Reconpatch: Contrastive patch representation learning for industrial anomaly detection. In Proceedings of the IEEE/CVF\nWinter Conference on Applications of Computer Vision,\npages 2052–2061, 2024. 3\n[19] Jongheon Jeong, Yang Zou, Taewan Kim, Dongqing Zhang,\nAvinash Ravichandran, and Onkar Dabeer. Winclip: Zero/few-shot anomaly classification and segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision\nand Pattern Recognition, pages 19606–19616, 2023. 1, 2, 3,\n7\n[20] Daniel S Kermany, Michael Goldbaum, Wenjia Cai, Carolina CS Valentim, Huiying Liang, Sally L Baxter, Alex\nMcKeown, Ge Yang, Xiaokang Wu, Fangbing Yan, et al.\nIdentifying medical diagnoses and treatable diseases by\nimage-based deep learning. cell, 172(5):1122–1131, 2018.\n6, 2\n[21] Soopil Kim, Sion An, Philip Chikontwe, Myeongkyun Kang,\nEhsan Adeli, Kilian M Pohl, and Sang Hyun Park. Few shot\npart segmentation reveals compositional logic for industrial\nanomaly detection. In Proceedings of the AAAI Conference\non Artificial Intelligence, pages 8591–8599, 2024. 2, 3\n[22] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao,\nChloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. Segment anything. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4015–4026, 2023. 2, 3,\n8, 9\n[23] Bennett Landman, Zhoubing Xu, J Igelsias, Martin Styner,\nThomas Langerak, and Arno Klein. Miccai multi-atlas labeling beyond the cranial vault–workshop and challenge.\nIn Proc. MICCAI Multi-Atlas Labeling Beyond Cranial\nVault—Workshop Challenge, page 12, 2015. 2, 6\n[24] Shilong Liu, Zhaoyang Zeng, Tianhe Ren, Feng Li, Hao\nZhang, Jie Yang, Chunyuan Li, Jianwei Yang, Hang Su, Jun\nZhu, et al. Grounding dino: Marrying dino with grounded\npre-training for open-set object detection. arXiv preprint\narXiv:2303.05499, 2023. 2, 8, 9\n[25] Tongkun Liu, Bing Li, Xiao Du, Bingke Jiang, Xiao Jin, Liuyi Jin, and Zhuo Zhao. Component-aware anomaly detection framework for adjustable and logical industrial visual\ninspection. Advanced Engineering Informatics, 58:102161,\n2023. 2, 3, 7\n[26] Yun Peng, Xiao Lin, Nachuan Ma, Jiayuan Du, Chuangwei\nLiu, Chengju Liu, and Qijun Chen. Sam-lad: Segment anything model meets zero-shot logic anomaly detection. arXiv\npreprint arXiv:2406.00625, 2024. 3\n[27] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya\nRamesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry,\nAmanda Askell, Pamela Mishkin, Jack Clark, et al. Learning\ntransferable visual models from natural language supervision. In International conference on machine learning, pages\n8748–8763. PMLR, 2021. 1, 3\n[28] Tianhe Ren, Shilong Liu, Ailing Zeng, Jing Lin, Kunchang\nLi, He Cao, Jiayu Chen, Xinyu Huang, Yukang Chen, Feng\n\n10\n\n\fAppendix\n\nA. Pseudocode Descriptions\n\nAlgorithm 1 Pseudocode of C 3 in a PyTorch style.\n\nIn this section, we present Pytorch-style pseudocode for the\nthree proposed modules: Contextual Component Clustering (C 3 ), Component-Aware Patch Matching (CAPM), and\nGraph-Enhanced Component Modeling (GECM). These\npseudocode representations aim to provide readers with a\nclearer and more structured understanding of the implementation details for each module. Specifically, the descriptions\ncover key processes such as mask filtering in the C 3 module, patch matching in the CAPM module, and component\nfeature aggregation in the GECM module. Algorithm 1, Algorithm 2, and Algorithm 3 illustrate the pseudocode for\nthese three modules, respectively.\nIn the GECM module, a graph structure is employed to\nenhance the interaction modeling of features for each component in the image. Specifically, the features of individual components, obtained through group average pooling,\nare treated as nodes in the graph. The edges between these\nnodes are weighted based on the cosine similarity between\ntheir corresponding features, capturing the relational structure within the image.\nTo further model these relationships, we leverage a\ntraining-free graph attention mechanism, which facilitates\nthe exchange of information among the graph’s nodes. In\nthis approach, the feature of each node simultaneously\nserves as the Query (Q), Key (K), and Value (V). The attention mechanism is computed using the following formula:\n\ndef C_3(image):\n\n\u0012\nAttention(Q, K, V ) = norm\n\nQ · KT\n√\ndk\n\n# generate M_sam\ntags = RAM(image)\nM_sam = Grounded_SAM(image, tags)\nM, H, W = M_sam.shape\n# when M_sam contains only one mask\nif len(M_sam) == 1:\narea_ratio = M_sam[0].sum() / (H * W)\nif area_ratio &gt; gamma:\nreturn ones_like(image)\nelse:\nreturn M_sam\n# generate M_cluster\nimage_features = image_encoder(image)\ncluster_centers = Cluster(image_features)\n# calculate feature similarity\nM_cluster = sim(\nimage_features, cluster_centers\n).argmax()\n# combine masks\nfor mask in M_sam:\nlabel[mask] = iou(mask, M_cluser).argmax()\nM_final[label[mask]].add(mask)\nreturn M_final\n\nacross 15 different object categories. This includes 4,096\nnormal images and 1,258 anomalous images, with resolutions ranging from 700×700 to 1,024×1,024. The dataset\ncovers various common industrial products, such as wooden\nboards, leather, metal components, and pills.\nVisA [38] is a relatively recent and widely used industrial\nanomaly detection dataset, containing 10,821 images across\n12 object categories. It includes 2,162 anomalous images,\nwith resolutions around 1,500×1,000 pixels.\nMVTec LOCO [5] is a dataset for logical anomaly detection. It is currently the largest logical anomaly detection\ndataset, containing 2,076 normal images and 1,568 anomalous images across 5 object categories. The anomalies in\nthe dataset include both structural anomalies such as damage or defects, and logical anomalies such as the addition,\nomission, or incorrect combination of elements. The dataset\nprovides pixel-level annotations of the anomalies.\nBrainMRI [2] dataset is based on the BraTS2021 [1]\ndataset, one of the latest large-scale brain tumor segmentation datasets. It contains complete 3D brain volume images.\nThe BrainMRI dataset consists of 2D slices derived from\nBraTS2021, with each slice image measuring 240×240 pix-\n\n\u0013\nV,\n\n(14)\n\nwhere norm(·) represents a normalization operation that\nensures each row of the attention matrix sums to 1. A\nwidely used normalization technique is the sof tmax(·)\nfunction, which applies an exponential scaling to emphasize\nrelative importance among nodes. This approach allows for\neffective and efficient feature interaction modeling, leveraging the inherent structure of the graph without requiring\nadditional training.\n\nB. Dataset Details\nWe conduct extensive experiments on UniVAD using nine\ndifferent datasets from the fields of industrial anomaly detection, logical anomaly detection, and medical anomaly\ndetection, respectively. The following provides a detailed\ndescription of each dataset:\nMVTec-AD [4] is one of the most popular datasets for industrial anomaly detection tasks, consisting of 5,354 images\n1\n\n\fAlgorithm 2 Pseudocode of CAPM in a Pytorch style.\n\nAlgorithm 3 Pseudocode of GECM in a Pytorch style.\n\ndef CAPM(image, normal_image, text_features):\n# get patch features\nquery_feat = image_encoder(image)\nnormal_feat = image_encoder(normal_image)\nquery_patches = Interpolate(\nquery_feat, size=image_size/patch_size\n)\nnormal_patches = Interpolate(\nnormal_feat, size=image_size/patch_size\n)\n\ndef GECM(image, normal_image):\n# extract features\nquery_feat = image_encoder(image)\nnormal_feat = image_encoder(normal_image)\nquery_masks = C_3(image)\nnormal_masks = C_3(normal_image)\nquery_com_feat = {\"deep\": [], \"geo\": []}\nnormal_com_feat = {\"deep\": [], \"geo\": []}\n\n# calculate score_pm\ndistance_matrix = cos_distance(\nquery_patches, normal_patches\n)\nscore_pm = distance_matrix.min()\n\n# CFA: Component Feature Aggregator\n# GAP: Group Average Pooling\nquery_com_feat[\"deep\"] = CFA(\nGAP(query_feat, query_masks)\n)\nnormal_com_feat[\"deep\"] = CFA(\nGAP(normal_feat, normal_masks)\n)\n\n# calculate score_aware and score_vl\nquery_masks = C_3(image)\nnormal_masks = C_3(normal_image)\n\nquery_com_feat[\"geo\"] = geo_encoder(\nquery_feat, query_masks\n)\nnormal_com_feat[\"geo\"] = geo_encoder(\nnormal_feat, normal_masks\n)\n\nfor mask, normal_mask in zip(\nquery_masks, normal_masks\n):\ndistance_matrix = cos_distance(\nquery_patches[mask],\nnormal_patches[normal_mask]\n)\nscore_capm[mask] = distance_matrix.min()\n\n# calculate scores\nfor mask in query_masks:\ndis_deep[mask] = cos_distance(\nquery_com_feat[\"deep\"][mask],\nnormal_com_feat[\"deep\"][normal_masks]\n)\n\nscore_vl[mask] = cos_distance(\nquery_patches[mask], text_features\n)\nreturn (score_pm + score_aware + score_vl) / 3\n\ndis_geo[mask] = cos_distance(\nquery_com_feat[\"geo\"][mask],\nnormal_com_feat[\"geo\"][normal_masks]\n)\n\nels. The training set includes 7,500 normal samples, and the\ntest set contains 3,715 samples, both normal and anomalous, with pixel-level anomaly annotations.\nLiverCT [2] dataset is constructed from the BTCV [23] and\nLiTS [6] datasets. It contains 50 normal abdominal 3D CT\nscans from BTCV and 131 abdominal 3D CT scans, both\nnormal and anomalous, from LiTS. The Hounsfield Unit\n(HU) values of the 3D scans from both datasets are converted to grayscale using the abdominal window and then\ncropped into 2D slices. The dataset includes 1,452 normal\n2D slices for training and 1,493 2D slices, both normal and\nanomalous, for testing, with a resolution of 512×512 and\npixel-level anomaly annotations.\nRESC [15]: The Retinal Edema Segmentation Challenge\n(RESC) dataset is a retinal OCT dataset containing 4,297\nnormal images for training and 1,805 test images, both normal and anomalous. The image resolution is 512×1,024,\nand the dataset provides pixel-level anomaly annotations.\nOCT17 [20] is another retinal OCT dataset, which includes\n26,315 normal training images and 968 test images, both\nnormal and anomalous, with a resolution of 512×496. The\ndataset only provides image-level anomaly annotations.\nChestXray [32] dataset is a commonly used X-ray dataset\n\nscore_deep[mask] = dis_matrix_deep.min()\nscore_geo[mask] = dis_matrix_geo.min()\n\nreturn (score_deep + score_geo) / 2\n\nfor detecting pulmonary abnormalities. It contains 8,000\nnormal images for training and 17,194 test images, both\nnormal and anomalous, with a resolution of 1,024×1,024.\nThe dataset provides image-level anomaly annotations.\nHIS [2] dataset is cropped from the Camelyon16 [3]\ndataset, which includes 400 whole-slide images of lymph\nnode biopsies stained with hematoxylin and eosin from\nbreast cancer patients. The HIS dataset includes 6,091\nnormal image patches and 997 anomalous image patches,\nwith a resolution of 256×256 pixels. The dataset provides\nimage-level anomaly annotations.\n\nC. Few-Abnormal-Shot Setting\nOne of the key features of UniVAD is its robust generalization capability. Without requiring any training on domain2\n\n\fPart 2: Component-Aware Patch Matching\nNormal Texts\nAbnormal Texts\n\nText\nEncoder\n\nUnified Inputs\n\nTn Ta\n\nCosine Similarity\n……\n\nIndustrial Inputs\n\nLogical Inputs\n\nQuery Patches\n\nMedical Inputs\n\nNN\nPart 1: Contextual Component Clustering\n\nQuery Component Patches\n\nNN\nStructural\nAnomaly Map\n\nPatch\nFeatures\nNormal Patches\n\nNormal Component Patches\n\nAdapter\nQuery Image\n\nContextual\nComponent\nClustering\n\nQuery\nComponents\n\nImage\nEncoder\n\nPart 3: Graph-Enhanced Component Modeling\n\nVAD Result\nComponent Feature\nAggregator\n\nNormal Images\n\nFrozen Modules\n\nNormal\nComponents\nTrained Modules\n\nQuery Component\nFeatures\n\nNN\n\nComponent\nFeatures\n\nLogical\nAnomaly Map\n\nNN: Nearest Neighbor Search\n\nNormal Component\nFeatures\n\nTn &amp; Ta ： Normal and Abnormal Text Features\n\nFigure 6. The overall architecture of UniVAD with a trainable adapter under few-abnormal-shot seeting.\n\nAlgorithm 4 Adapter Module\nInput: vector x\nOutput: vector y\n1: h1 = ReLU(W1 x + b1 )\n2: y = SiLU(W2 h1 + b2 )\n\nspecific anomaly detection datasets, UniVAD demonstrates\noutstanding cross-domain anomaly detection performance\nby using only a minimal number of normal samples as a\nreference during the testing phase.\nOn the other hand, for scenarios demanding highprecision detection on specific domain data, we provide a\ndomain adaptation training method. This method allows\nUniVAD to be fine-tuned on domain-specific datasets to\nachieve optimal performance for particular tasks. Such finetuning requires only a small number of normal and anomalous samples from the target dataset, which is referred to as\nthe few-abnormal-shot setting.\n\nD. More ablation study results\nIn this section, we present a more detailed ablation study\nof the various components of our proposed method. This\nincludes an analysis of the hierarchical levels of features\nextracted by the image encoder, the geometric features utilized in the GECM module, the distance metrics employed\nin score computation, the number of normal samples considered, and other relevant factors. Below are the detailed\nanalyses for each aspect.\n\nIn Section 4, in addition to the default few-normal-shot\nsetting, we conduct experiments using the few-abnormalshot setting and compare its performance with other methods under the same configuration. The experimental results\nsignificantly outperform existing approaches, demonstrating that UniVAD combines strong generalization capabilities with exceptional accuracy for domain-specific tasks.\n\nD.1. Structural Anomalies and Logical Anomalies\nEach category in the MVTec LOCO dataset contains both\nstructural and logical anomalies. UniVAD’s CAPM module and GECM module are particularly adept at detecting\none type of anomaly each. In Table 7, we compare the detection performance of the CAPM and GECM modules on\nthe MVTec LOCO dataset, highlighting the complementary\ncollaboration between the two modules.\n\nTraining UniVAD for domain adaptation under the fewabnormal-shot setting requires only minimal modifications\nto the original model: adding an adapter after the image\nencoder, as illustrated in Figure 6.\nRegarding the adapter’s structure, we adopt bottleneck\narchitecture, which is commonly used in computer vision\nand natural language processing. The specific structure,\nshown in Algorithm 4, consists of two linear layers, one\nReLU activation layer, and one SiLU activation layer.\n\nD.2. Normal Samples\nUniVAD can perform anomaly detection and localization\nacross various domains with only a single normal sample as\n3\n\n\fMVTec LOCO Logical\n\nModule\n\nMVTec LOCO Structural\n\nImage-level AUC\n\nPixel-level AUC\n\nImage-level AUC\n\nPixel-level AUC\n\n59.9\n65.0\n65.9\n\n66.9\n71.2\n72.4\n\n82.2\n56.9\n82.6\n\n93.0\n82.6\n93.5\n\nCAPM Only\nGECM Only\nUniVAD\n\nTable 7. Ablation studies of CAPM and GECM modules on MVTec LOCO datasets. The best performance results are in bold.\n\nMVTec-AD\n\n97.5\n\n96\n\n95.0\n\n94\n\n92.5\n\n92\n\n1\n\n2\n\nshot\n\n90.0\n\n4\n\n1\n\n4\n\n100\n95\n90\n85\n80\n75\n70\n65\n60 1\n\nBrainMRI\n\n100\n95\n85\n\nAUC\n\nAUC\n\n90\n80\n75\n1\n\n2\n\nshot\n\n70\n65\n\n85.0\n2\n\nshot\n\n4\n\n1\n\nLiverCT\n\n2\n\nshot\n\n4\n\nRESC\n\n100\n95\nAUC\n\n88\n\n75\n\n87.5\n\nImage-Level AUC\nPixel-Level AUC\n\nMVTec LOCO\n\n80\n\nAUC\n\n98\n\n90\n\nVisA\n\n100.0\n\nAUC\n\nAUC\n\n100\n\n90\n85\n80\n\n2\n\nshot\n\n4\n\n1\n\n2\n\nshot\n\n4\n\nFigure 7. Experimental results of UniVAD under 1-normal-shot, 2-normal-shot, and 4-normal-shot settings.\n\na reference. To further evaluate its performance, we conducted experiments under settings where multiple normal\nsamples were provided as references. Specifically, experiments were performed with 1, 2, and 4 normal samples.\nThe experimental results under different numbers of normal\nsamples are presented in Fig. 7. The results demonstrate\nthat the anomaly detection performance improves progressively as the number of normal samples increases.\n\nThe utilization of multi-level features enhances the representation capacity for features at varying levels of abstraction within the image, thereby improving anomaly detection\nperformance. Table 8 compares the anomaly detection performance when using features from a single layer versus\nemploying multi-level features.\n\nD.4. Geometric Features\n\nD.3. Multi-level Features\n\nIn the GECM module, in addition to leveraging the deep\nfeatures of each component, we also incorporate the geometric features of each component to assess logical anomalies. In UniVAD, three geometric features, i.e. area, color,\nand position, are extracted for each component and concatenated into a single vector. Table 9 presents a comparison\nof anomaly detection performance across different datasets\nwhen only subsets of the geometric features are utilized.\nThe results demonstrate that each geometric feature contributes significantly to the overall performance.\n\nNumerous studies have demonstrated that image features\nextracted from different intermediate layers of an image\nencoder exhibit distinct characteristics. Shallow-layer features predominantly capture basic graphical properties such\nas colors and edges, while deep-layer features encapsulate\nmore complex and abstract semantic information, including\nstructures and textures. In UniVAD, four hierarchical feature maps are extracted from the input image, corresponding\nto layers 6, 12, 18, and 24 of the CLIP-ViT image encoder.\n4\n\n\fTask\n\nDataset\n\nLayer 6 Only\n\nLayer 12 Only\n\nLayer 18 Only\n\nLayer 24 Only\n\nUniVAD\n\nImage-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n96.5\n91.1\n70.4\n68.9\n59.0\n78.2\n\n96.9\n90.3\n68.9\n66.2\n63.4\n84.1\n\n97.1\n90.3\n68.7\n73.9\n64.4\n84.1\n\n96.5\n90.5\n66.7\n68.8\n65.5\n83.5\n\n97.8\n93.5\n71.0\n80.2\n70.0\n85.5\n\nPixel-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n96.3\n95.6\n74.7\n95.3\n96.0\n91.5\n\n96.8\n97.9\n74.6\n95.8\n94.2\n94.3\n\n96.5\n97.9\n75.5\n96.9\n94.9\n94.6\n\n95.7\n97.3\n73.2\n95.4\n96.0\n94.0\n\n96.5\n98.2\n75.1\n96.8\n96.3\n94.9\n\nTable 8. Ablation studies of multi-level feature utilization across different datasets. The best performance results are in bold.\n\nD.5. Image Resolution\n\nE. Experimental Results in More Scenarios\n\nIn the experiments presented in the main text, we adopt a\nresolution of 448×448 to remain consistent with existing\nmainstream anomaly detection methods. To evaluate the\nperformance of the method in scenarios with limited computational resources, we also test UniVAD at resolutions of\n224×224 and 336×336. The experimental results shown\nin Fig. 8 demonstrate that, although UniVAD experiences a\nslight performance drop under lower-resolution settings, it\nstill achieves satisfactory results.\n\nTo further illustrate the versatility and robustness of UniVAD, we conduct experiments in various scenarios beyond\nstandard anomaly detection datasets. These include realworld wood defect detection and crack segmentation tasks,\nboth of which pose unique challenges and practical significance in industrial and structural inspection applications.\n\nE.1. Real-World Wood Defect Detection\nWood, as one of the most commonly used and indispensable\nmaterials in industrial production, necessitates effective defect detection to ensure quality and reduce waste. To evaluate UniVAD’s applicability in this domain, we collected a\ndataset comprising real-world wood samples from production environments and applied UniVAD for defect detection. The results, visualized in Figure 9 (a), demonstrate\nUniVAD’s strong adaptability and generalization ability in\nthis challenging real-world setting.\n\nD.6. Distance Calculation Method\nIn the CAPM and GECM modules, UniVAD calculates the\ndistances between image patch features and component features, respectively. By default, we use cosine distance for\nthese calculations, as described in the paper. Additionally,\nwe evaluated UniVAD’s performance using L1 distance and\nL2 distance. The comparative experimental results are presented in Table 10. The results indicate that cosine distance\nachieves the best detection performance.\n\nE.2. Crack Segmentation\nCrack segmentation, which involves detecting and delineating cracks on surfaces such as concrete, bricks, or other\nstructural materials, is a critical task in applications like\ninfrastructure maintenance and surface inspection. Given\nthe significant implications for safety and cost-efficiency,\neffective methods for this task are highly valued. We evaluated UniVAD on a dedicated crack segmentation dataset,\nassessing its performance in few-shot scenarios where limited training data are available. As shown in Figure 9 (b),\nUniVAD achieves excellent segmentation accuracy on the\nCrackVision dataset, effectively identifying cracks even on\ncomplex and textured surfaces. These results further emphasize UniVAD’s capability to address diverse and intricate anomaly detection tasks.\n\nD.7. Clustering Method\nIn the C 3 module, we generate Mcluster by clustering\nimage features to filter and control the granularity of\nMsam produced by Grounded SAM. The clustering method\nused in the paper is KMeans. To investigate the impact\nof different clustering methods on performance, we also\ncompared Meanshift, DBSCAN, and Spectral Clustering.\nThe comparative results, summarized in Table 11, show\nthat anomaly detection performance is highest when using\nKMeans or Spectral Clustering, while Meanshift and DBSCAN yield slightly inferior results.\n5\n\n\fTask\n\nDataset\n\nw/o Geo Feat.\n\nArea Only\n\nArea + Color\n\nArea + Color + Position\n\nImage-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n97.4\n92.0\n69.8\n79.7\n66.4\n83.9\n\n97.3\n92.0\n70.6\n79.4\n67.9\n84.2\n\n97.6\n92.7\n70.8\n79.6\n68.9\n84.9\n\n97.8\n93.5\n71.0\n80.2\n70.0\n85.5\n\nPixel-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n96.6\n98.1\n72.4\n96.8\n94.8\n94.4\n\n96.6\n98.1\n72.1\n96.8\n95.7\n94.4\n\n96.5\n98.0\n74.9\n96.8\n96.2\n94.7\n\n96.5\n98.2\n75.1\n96.8\n96.3\n94.9\n\nTable 9. Ablation studies of geometric features across different datasets, Geo feat. represent components geometric features. The best\nperformance results are in bold.\n\n100\n\nVisA\n\n100\n80\n\n60\n\n60\n\n60\n\n40\n\n0 224\n100\n\n40\n20\n\nImage-Level AUC\nPixel-Level AUC\n\n336\nResolution\n\nAUC\n\n80\nAUC\n\n80\n\n20\n\n448\n\nBrainMRI\n\n0 224\n100\n\n40\n\n336\nResolution\n\n448\n\nLiverCT\n\n0 224\n100\n\n80\n\n80\n\n80\n\n60\n\n60\n\n60\n\n40\n20\n0 224\n\n40\n20\n\n336\nResolution\n\n448\n\n0 224\n\nMVTec LOCO\n\n20\n\nAUC\n\nAUC\n\nMVTec-AD\n\nAUC\n\nAUC\n\n100\n\n336\nResolution\n\n448\n\n336\nResolution\n\n448\n\nRESC\n\n40\n20\n\n336\nResolution\n\n448\n\n0 224\n\nFigure 8. Experimental results of UniVAD at different resolutions.\n\n6\n\n\fTask\n\nDataset\n\nL1 distance\n\nL2 distance\n\nCosine distance\n\nImage-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n94.8\n87.6\n66.4\n59.3\n54.2\n83.4\n\n93.8\n87.5\n62.1\n60.2\n53.3\n82.5\n\n97.8\n93.5\n71.0\n80.2\n70.0\n85.5\n\nPixel-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n95.3\n96.7\n75.1\n95.6\n95.9\n92.6\n\n95.7\n97.1\n69.7\n95.4\n96.0\n95.7\n\n96.5\n98.2\n75.1\n96.8\n96.3\n94.9\n\nTable 10. Ablation studies of distance calculation method across different datasets. The best performance results are in bold.\n\nTask\n\nDataset\n\nMeanShift\n\nDBSCAN\n\nSpectral Clustering\n\nKmeans\n\nImage-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n96.3\n91.5\n68.7\n76.9\n67.7\n85.5\n\n97.0\n91.1\n70.4\n59.2\n67.7\n85.5\n\n97.8\n93.5\n71.8\n77.8\n67.9\n85.5\n\n97.8\n93.5\n71.0\n80.2\n70.0\n85.5\n\nPixel-level\n(AUC)\n\nMVTec-AD\nVisA\nMVTec LOCO\nBrainMRI\nLiverCT\nRESC\n\n95.4\n96.9\n73.1\n96.6\n96.5\n94.9\n\n95.1\n97.6\n74.0\n89.2\n96.5\n94.9\n\n96.4\n98.2\n74.5\n96.6\n96.8\n94.9\n\n96.5\n98.2\n75.1\n96.8\n96.3\n94.9\n\nTable 11. Ablation studies of clustering method across different datasets. The best performance results are in bold.\n\nNormal\nImage\n\nQuery\nImage\n\nVAD\nResult\n\nGround\nTruth\n\n(a) Real-World Wood Defect Detection\n\n(b) Crack Segmentation\n\nFigure 9. Visualization results in real-world wood defect detection and crack segmentation scenarios.\n\n7\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"