"<!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>Dual-Interrelated Diffusion Model for Few-Shot Anomaly Image Generation\nYing Jin1∗ , Jinlong Peng2 *, Qingdong He2∗ , Teng Hu3 , Jiafu Wu2 , Hao Chen1\nHaoxuan Wang1 , Wenbing Zhu1 , Mingmin Chi1†, Jun Liu2 , Yabiao Wang2,4†\n1\nFudan University, 2 Youtu Lab, Tencent, 3 Shanghai Jiao Tong University, 4 Zhejiang University\n\narXiv:2408.13509v3 [cs.CV] 29 Apr 2025\n\n{yjin22, haochen22, hxwang23, wbzhu23}@m.fudan.edu.cn, mmchi@fudan.edu.cn\n{jeromepeng, yingcaihe, jiafwu, juliusliu}@tencent.com, hu-teng@sjtu.edu.cn, yabiaowang@zju.edu.cn\n\nhttps://github.com/yinyjin/DualAnoDiff\n\nAbstract\nThe performance of anomaly inspection in industrial manufacturing is constrained by the scarcity of anomaly data.\nTo overcome this challenge, researchers have started employing anomaly generation approaches to augment the\nanomaly dataset. However, existing anomaly generation methods suffer from limited diversity in the generated anomalies and struggle to achieve a seamless blending of this anomaly with the original image. Moreover,\nthe generated mask is usually not aligned with the generated anomaly. In this paper, we overcome these challenges from a new perspective, simultaneously generating\na pair of the overall image and the corresponding anomaly\npart. We propose DualAnoDiff, a novel diffusion-based fewshot anomaly image generation model, which can generate diverse and realistic anomaly images by using a dualinterrelated diffusion model, where one of them is employed\nto generate the whole image while the other one generates the anomaly part. Moreover, we extract background\nand shape information to mitigate the distortion and blurriness phenomenon in few-shot image generation. Extensive experiments demonstrate the superiority of our proposed model over state-of-the-art methods in terms of diversity, realism and the accuracy of mask. Overall, our\napproach significantly improves the performance of downstream anomaly inspection tasks, including anomaly detection, anomaly localization, and anomaly classification\ntasks. Code will be made available.\n\n1. Introduction\nIndustrial anomaly inspection, i.e., anomaly detection, localization, and classification, plays an important role in in* Equal contribution.\n† Corresponding author (This work was supported by Natural Science\n\nFoundation of China under contract 62171139).\n\nValid\n\nReality\n\nAlign\n\nLocation\n\ngrid\n\nleather\n\nhazelnut\n\nscrew\n\nMVTec\n\nDFMGAN\nAAAI’23\n\nAnomaly\nDiffusion\nAAAI’24\n\nOurs\n\nprompts\n\nFigure 1. Top: Evaluating anomaly generation quality in four aspects: Whether generate valid anomaly, degree of realism, alignment of the mask, and whether the location of mask is reasonable,\nthe results show that our generated results are better than the other\nmethods. (Yellow area represents the valid generation, green indicates the correct mask or area, red indicates the generated mask\nor wrong area.) Bottom: Our model can simultaneously generate\nextensive anomaly image-mask pairs.\n\ndustrial manufacture [6]. However, in real-world industrial production, anomaly samples are scarce. Therefore,\nthe current mainstream anomaly inspection methods are either unsupervised methods which use only normal samples\n[22, 36] or semi-supervised method [48] which employ both\nthe normal samples and a few anomaly data. Although these\nmethods perform well in anomaly detection, they have limited performance in anomaly localization and can not deal\nwith the task of anomaly classification [14]. Therefore, researchers proposed anomaly generation methods to gener-\n\n\fate more anomaly data, to help achieve better performance\nby using supervised anomaly inspection.\nExisting anomaly generation methods can be categorized\ninto two groups, 1) model-free methods randomly cut and\npaste patches from existing anomalies or anomalous texture\ndatasets onto normal samples [20, 23, 46]. But the anomaly\ndata synthesized by them are unrealistic. 2) Generative\nmethods employ generative models like GANs and diffusion models to generate anomaly data. Generally, GANbased model [26, 47] requires a large amount of training\ndata to achieve better generation performance and they can\nnot generate masks. DFMGAN [6] is firstly trained on normal data and then migrated to anomaly data to achieve a\nfew-shot generation. This method also encounters the problem that the generated anomalies are not realistic enough\n[29] and the masks are not sufficiently aligned [21] because\nthere is no explicit alignment constraint design. AnomalyDiffusion [14] based on the texture-inversion [7] technique\nof Diffusion [33], separately learns the anomaly appearance\nand location information, then generates the anomaly on\nthe masked normal samples. As AnomalyDiffusion only\nfocuses on the part of anomaly, the generated anomalies\ndo not blend realistically with the original image, and the\nmasks generated individually may appear in the background\nof image. To address these limitations, we propose DualAnoDiff, a novel few-shot anomaly image generation model\nthat utilizes a dual-interrelated diffusion to simultaneously\ngenerate the overall image and the corresponding anomaly\npart. This approach can realize the effective integration of\nanomaly image and anomaly part, resulting in the generation of realistic and highly aligned anomaly image-mask\ndata pairs with good diversity. Specifically, our model is\nbuilt upon a pre-trained diffusion model and introduces two\nLoRA [12] to expand a single diffusion model into dualinterrelated diffusion model. One branch, referred to as\nthe global branch, is responsible for generating the overall anomaly image, while the anomalous branch generates\nthe localized anomaly image. They exchange information\nthrough the self-attention interaction module. This module combines the attention layers of global and anomalous branches and performs shared attention calculations,\nenabling the interaction and fusion of information in the\ndual-denoising process. This ensures the consistency between the generated overall anomaly image and the localized anomaly image. Furthermore, to further preserve the\ninvariance of the background, we introduce a background\ncompensation module based on self-attention adaptive injection. This module involves adding noise to the background image, extracting the key and value from the intermediate feature layer, and applying adaptive fusion MLP\nto incorporate the background information into the global\nbranch. It contributes to maintaining the accuracy of the\nbackground and the shape of the object in the generated im-\n\nages, while avoiding the coupling between the object and\nthe background in the images.\nFig.7 shows our generated results outperform those of\nother methods in four key aspects. Moreover, extensive experiments have been conducted on MVTec AD [1] to quantitatively validate the superiority of the anomaly data generated by DualAnoDiff in downstream anomaly inspection\ntasks, and achieving a state-of-the-art level of performance\nin pixel-level anomaly detection with 99.1% AUROC and\n84.5% AP score.\nOur contributions can be summarized as follows:\n• We propose DualAnoDiff, a novel few-shot diffusionbased anomaly generation method, which simultaneously\ngenerates both the overall image and the corresponding anomaly part with a highly aligned mask by a dualinterrelated diffusion model.\n• We design a background compensation approach, which\ninvolves image backgrounds as control information and\ninjects the intermediate feature into the denoising process\nof anomaly image, to enhance the stability and realism of\nthe generated data.\n• Extensive experiments demonstrate the superiority of our\nmethod over existing anomaly generation models in terms\nof both generation quality and performance of downstream anomaly inspection tasks.\n\n2. Related Work\n2.1. Few-shot Image Generation\nFew-shot image generation aims to generate new and diverse examples while preventing overfitting to the few training images [45, 51]. It is highly susceptible to overfit with\nextremely limited training data (less than 10) and then generate highly similar images. FreezeD [25] proposes modifying network weights, using various regularization techniques and data augmentation to prevent overfitting [14].\nThere are also methods [13] to mitigate overfitting by pretraining on the source domain and subsequently migrating\nto fewer samples through cross-domain consistency losses\nto keep the generated distribution. Textual Inversion [7]\nand Dreambooth [37] encode a few images into the textual\nspace of a pre-trained diffusion model to achieve diverse\ntarget customization generation which preserves its key visual features. Although these methods can generate realistic\nimages, they are incapable of generating pixel-level annotations which are essential for anomaly image generation\ntasks. In contrast, our method enables high-quality annotations to be readily obtained by simultaneously generating\nlocal anomaly images.\n\n2.2. Anomaly Inspection\nThe anomaly inspection task consists of anomaly detection, localization, and classification [6]. Due to the scarcity\n\n\fbwc\n\nbwc\n\n𝜑i (𝑧) 𝜑i (𝑧’)\n\n𝑄\n\n𝐾\n\n𝑉\n\n𝑄\n\n𝑀𝐿𝑃\n\nWeight sharing\n\n𝐾\n\n𝑉\n\nbw 2 c\n\nselfattention\n\n𝑧\n\n𝑄\n\n𝐾\n\n𝑉\n\n+\n\n𝜑i (𝑧)\n\n𝑆𝐷\n\nI\n\n𝑄\n\n𝐾\n\n𝑉\nI\n\n𝜑i (𝑧)′\n\nSAIM\n\nGT\n𝑧’\n\n𝑄\n\n𝐾\n\n𝑉\n\nSAIM\n\nsks\n\n𝜑i (𝑧)′ 𝜑i (𝑧’)′\nbwc\n\n𝜑i (𝑧’)′\n\n𝜑i (𝑧’)\n\nIa\n\nrearrange\n\na vfx with sks\n\nMo\n\nCLIP\n\nSegmentor\n\nCLIP\n\nIb\n\n+\n\n𝑄\n\n𝐾\n\n𝑉\n\nSegmentor\n\nIa\n\n𝑆𝐷∗\n\nbwc\n\nMa\n\nFigure 2. The architecture of DualAnoDiff. 1) Two branches of DualAnoDiff generate the anomaly image and corresponding anomaly\npart simultaneously with different but nested prompts. 2) Two branches share the attention information after every attention block by\nSelf-Attention Interaction Module (SAIM) during the denoising process to keep the consistency of generated images. 3) Background\nCompensation Module (BCM) extracts the Key, and Value of the background image and applies an adaptive fusion to SD, to help the\nmodel more focus on the object of the image.\n\nof abnormal data in industrial scenarios, most methods\n[9, 18, 22, 24, 36, 40–42] use unsupervised methods and\nsemi-supervised methods. Reconstruction-based methods\n[3, 10, 39] detect anomalies by analyzing the residual image\nbefore and after reconstruction. Embedding-based methods [2, 19, 44] utilize pre-trained networks to extract the\nimage-level features and patch-level features, and then perform clustering according to the similarity between the features to detect the anomalies. All of those methods can only\naddress the task of anomaly detection, while having limited\nperformance in anomaly localization and being incapable of\nanomaly classification. Through the generation of abnormal\nimages, these three tasks can be successfully accomplished,\nand our method achieves the state-of-the-art performance.\n\n2.3. Anomaly Generation\nDue to the scarcity of anomaly data, anomaly generation\nhas emerged as a field of crucial significance. DRAEM\n[46], Cut-Paste [20], Crop-Paste [23] and PRN [48] crop\nand paste unrelated textures or existing anomalies into normal sample. These approaches can be somewhat effective, but the generated anomalies are completely unrealistic and there is no way to use them as anomaly classification tasks. Subsequently, GANs [8] have been applied for\nanomaly generation due to their ability to generate highfidelity images. SDGAN [26] and DefectGAN [47] generate anomalies on normal samples by learning from anomaly\n\ndata. However, they require a large amount of anomaly data\nand cannot generate anomaly masks. DFMGAN [6] transfers a StyleGAN2 [15] pretained on normal samples to the\nanomaly domain, but lacks generation realism and accurate\nalignment between generated anomalies and masks. Subsequently, Diffusion models have been more widely used due\nto their extreme generalizability. AnomalyDiffusion [14]\nlearns the features of anomaly and the distribution of masks\nthrough text inversion [7] technique of diffusion, to generate the specified anomaly at the position of the corresponding mask of the normal image. However, Since the method\nlearns the anomaly part and the mask separately, it makes\nthe generated mask not necessarily located on the object,\nand the anomaly-object transition is not natural enough.\nNevertheless, through the utilization of a two-branch diffusion model along with a background supplement module,\nour methodology successfully accomplishes the full decoupling of diverse attributes within the anomaly image. As a\nresult, the generated data are more realistic and diversified,\nand the performance of various downstream tasks is significantly enhanced.\n\n3. Method\nGiven a set of a limited number of anomaly image-mask\npairs, our goal is to learn the features of the anomaly images, and then generate more anomaly image-mask pairs\n\n\fthat belong to the same item and anomaly type, while ensuring greater diversity in the distribution and appearance\nof the anomaly. In our method, we generate the overall image and the anomaly part, which is then segmented to get\nthe corresponding mask.\na\n\n3.1. Preliminaries\nLatent Diffusion Models. Stable Diffusion (SD), a variant\nof the latent diffusion model (LDM) [33], serves as a textguided diffusion model. To generate high-resolution images while enhancing computational efficiency in the training process, it employs a pre-trained variational autoencoder (VAE) [16] encoder E(·) to map images into latent\nspace and perform an iterative denoising process. Subsequently, the predicted images are mapped back into pixel\nspace through the pre-trained VAE decoder D(·). ϵθ is the\ndenoising network, for each denoising step, the simplified\noptimization objective is defined as follows:\n  L_{L D M}( \\theta )= \\mathbb {E}_{\\mathcal {E}(x), \\epsilon ,t} \\left [\\| \\epsilon -\\epsilon _{\\theta }\\left (z_{t}, t, \\tau _{\\theta }(c)\\right ) \\|_{2}^{2}\\right ] \n\n(1)\n\nwhere ϵ are latent noise, the text description c is encoded by\nthe CLIP [31] text encoder τθ (·) and then used to guide the\ndiffusion denoising process.\n\n3.2. DualAnoDiff Framework\nWe have been searching for methods that can generate both\nanomaly image and mask. Inspired by Layerdiffusion [49],\nwe decompose an anomaly image into two parts, the overall\nanomaly image and the corresponding anomaly part, where\nthe overall image refers to the whole anomaly image I,\nthe anomaly part refers to the part that contains only the\nanomaly region Ia . Ia = I × Ma (Ma is the mask of\nanomaly part).\nAs shown in Fig. 2, the proposed DualAnoDiff involves\ntwo interrelated diffusion models, and they share part information by the Self-attention Interaction Module. We freeze\nthe weights of diffusion models and use two LORA [12] to\nfine-tune them. For ease of description, we denote the two\ndiffusion models as SD and SD∗ , SD denote the diffusion\nmodel to generate global image I, SD∗ denote the diffusion\nmodel to generate anomaly part Ia .\nDual-Interrelated Diffusion. AnomalyDiffusion [14] primarily focuses on the anomaly part, which may result in\ngenerated anomaly images lacking a convincingly realistic\nappearance. However, generating the complete anomaly\nimage poses challenges in obtaining the corresponding\nmask. To address those limitations, our proposed model\nsimultaneously generates both the overall image and the\nanomaly part. This novel approach overcomes challenges\nin generating realistic anomaly images while ensuring the\navailability of accurate masks.\nFirst, we encode I, Ia into latent space z and z ′ , with\nz = ε(I) and z ′ = ε(Ia ) by using VAE encoder ε(·).\n\n𝑏\n\n𝑐\n\nFigure 3. a is the image generated by SD, b and c are the cross\nattention maps of different text tokens in SD corresponding to the\ntext of “a vfx with” and “sks”.\n\nNext we employ a forward process to add noise into the\nlatents with the same timestep t, and then learn to denoising\nduring the backward process guided by different prompts.\nThroughout these processes, information is shared and synchronized between the two diffusion models through the\nSAIM, enabling the model to effectively fit the training data\npairs. By generating the anomalies separately, this approach\nachieves two important objectives. Through a simple yet\neffective operation of adding two LoRA, it enhances the diversity and reality of the generated anomaly. Additionally,\nit ensures a highly aligned mask that accurately corresponds\nto the anomaly image.\nNested Prompts. The goal of the dual diffusion is to generate an anomaly image and anomaly part pair (I and Ia ),\nwhich exhibits an inclusion relationship. To facilitate the\nmodel’s understanding of the distinct entities within the image (the primary subject and the anomaly), we employ a\npair of prompts designed to reflect this inclusion relationship:\n  p: \\medspace &amp;a \\medspace \\mathbf x \\medspace with \\medspace \\mathbf y \\notag \\\\ p': \\medspace &amp; \\mathbf y\n(2)\nwhere the prompts p and p′ correspond to the anomaly\nimage I and the corresponding anomaly part Ia respectively. Both prompts are encoded by the trainable text encoder τθ (·) and then injected into Unet [34] of Diffusion.\nThe variables x and y can be the class name and anomaly\nname provided by the dataset. In our model, we use the\nvf x and sks which were suggested by DreamBooth [37].\nThose words have weak prior in both the language model\nand the diffusion model, making them easier to fit than other\nwords, and can achieve better generation results, specially\nfor high-prior words. Fig.3 presents the generated result and\nvisualizes the cross-attention maps between text token and\nvision. where a is the anomaly image generated by SD. b\nand c are the 64 × 64 resolutions feature maps randomly\nextracted from the second half of the generation process in\nthe Unet of SD. Where b corresponds to the text “a vf x\nwith”, c corresponds to “sks”. It is evident that the model\ncorrectly separates the attributes of anomaly and object, and\naccurately associating them to the specified text as we want.\nSelf-attention Interaction Module (SAIM). During training, SD and SD∗ share the same timestep t and denois-\n\n\f3.3. Background Compensation Module\n(a)\n\n(b)\n\nbottle\n\npill\n\ntoothbrush\n\nFigure 4. Comparison between the models without (a) and with\n(b) the Background Compensation Module.\n\ning simultaneously, they share information by SAIM after\nevery attention blocks in the Unet of diffusion. For example, after the self-attention blocks is more likely to share the\npositional information and detailed information, the crossattention blocks shares the semantic information.\nIn SAIM, we use attention to fuse the information from\ntwo branch, The shared step is formulated as:\n  \\varphi _{i}(\\tilde {z}) = Rearrange&amp;(Concat(\\varphi _{i}(z),\\varphi _{i}(z')))\\notag \\\\ \\varphi _{i}(\\tilde {z})_{new} =&amp; SelfAtt(\\varphi _{i}(\\tilde {z}))\\\\ \\varphi _{i}(z)',\\varphi _{i}(z')' = Split(&amp;Rearrange(\\varphi _{i}(\\tilde {z})_{new}+\\varphi _{i}(\\tilde {z}))) \\notag\n\nwhere φi is the intermediate representation of the Unet. The\noriginal shape of φi (z) and φi (z ′ ) are “b w c”, where “b”\ndenotes the batch size, “w” represents the spatial dimension, and “c” represents the channel dimension. We rearrange the Concat(φi (z), φi (z ′ )) to shape of “bw 2 c” to\navoid displacement in space. Concat and Split are a set\nof corresponding operations that are used to aggregate and\nseparate feature maps.\nLoss Function. With the two-stream structure of diffusion,\nour final training objective is expressed as follows:\n  \\mathcal {L}=&amp;\\mathbb {E}_{\\mathcal {E}(I), \\epsilon ,t} \\left [\\| \\epsilon -\\epsilon _{\\theta }\\left (z_{t}, t, \\tau _{\\theta }(p))\\right ) \\|_{2}^{2}\\right ]\\notag \\\\ &amp;+\\mathbb {E}_{\\mathcal {E}(I_{a}), \\epsilon ^\\ast ,t} \\left [\\| \\epsilon ^\\ast -\\epsilon _{\\theta }^\\ast \\left (z'_{t}, t, \\tau _{\\theta }(p')\\right ) \\|_{2}^{2}\\right ]\n(4)\n∗\n\nwhere, ϵ and ϵ are latent noise for the anomaly image and\nanomaly part, t is the time step, p, p′ are the corresponding\nprompts, they are encoded by text encoder τθ (·) which is\ntrainable.\nMask Generation. Thanks to our two-stream parallel\nstructure, which generates the anomaly part as a single entity, obtaining the precise mask becomes straightforward.\nThere are two ways to obtain a high-quality mask: 1). We\nutilize existing segmentation algorithms such as SAM [17],\nU2 -Net [30] to obtain high-quality masks after generating\nthe anomaly part image. 2) During the generation process,\nwe can extract the average attention maps in SD∗ to compute the mask such as [43] which is widely used in semantic\nsegmentation. In this paper, we use the first method.\n\nAlthough the model has achieved good results so far, there\nare still some problems in some cases, which is caused by\nthe limited training data. Several bad cases of corresponding generated results are shown in Fig.4 for categories bottle, pill, and toothbrush in the MVTec (the average training data for each category is 8). The bottle was only partially generated. The edges of pill is blurred and the internal properties leakage into the background. Additionally,\nthe toothbrush has two brush handles, which is an abnormal occurrence. Furthermore, all of those generated images\nlack sharpness and the background color does not maintain\nsufficient purity. In general, since the model is incapable\nof fully grasping the characteristics of those cases, there are\nproblems such as objects being mixed with the background\nand objects being deformed.\nTo enhance the model’s ability to learn the shape of object and focus more on object generation, we design a background compensation module. First, we employ U2 -Net\nto segment the image I and obtain the object mask Mf ,\nthen get the background image Ib = (1 − Mf ) × I, Ib\nwill be processed by the SD as same as I (except for the\nSAIM). Then, we utilize Ib as a condition, which contains\nboth background and mask information. This allows us to to\ncontrol the shape of the object while providing background\ncontext. We collect its features in self-attentions and inject\nthem into the K, V of the I in every corresponding selfattention steps. The injection process can be formulated as:\n\n  \\varphi _{i}(z^{b}) =&amp; SelfAtt(\\varphi _{i}(z^{b})) \\notag \\\\ Q =&amp; W^{(i)}_{Q}\\cdot \\varphi _{i}(z)\\notag \\\\ \\varphi _{i}(z) =&amp; \\varphi _{i}(z) + \\gamma MLP(\\varphi _{i}(z^{b})) \\notag \\\\ K = W^{(i)}_{K}\\cdot &amp;\\varphi _{i}(z) \\quad V = W^{(i)}_{V}\\cdot \\varphi _{i}(z)\n\n(5)\nwhere γ is a learnable scale factor initialized to be 0.1. This\ndesign can help us to maximally preserve the generative effect of the mainstream SD, meanwhile use background information and the shape of the mask. With the condition of\nIb , the loss function becomes:\n  \\mathcal {L}=&amp;\\mathbb {E}_{\\mathcal {E}(I), \\epsilon ,t}\\left [\\left \\|\\epsilon -\\epsilon _{\\theta }\\left (z_{t}, t, \\tau _{\\theta }(p),I_{b}\\right )\\right \\|_{2}^{2}\\right ]\\notag \\\\ &amp;+\\mathbb {E}_{\\mathcal {E}(I_{a}), \\epsilon ^\\ast ,t} \\left [\\left \\|\\epsilon ^\\ast -\\epsilon _{\\theta }^\\ast \\left (z'_{t}, t, \\tau _{\\theta }(p')\\right )\\right \\|_{2}^{2}\\right ]\n(6)\nFrom another perspective, the dual-branch structure is\nequivalent to explicitly separating the two concepts of the\nobject body and the anomaly in image. However, in the\ncase of some images with backgrounds, two attributes are\nnot enough. model may mix the object body with the solidcolor background, thus resulting in the phenomenon shown\nin Fig. 4(a). The BCM module further decouples the object\n\n\fCategory\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazel nut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nAverage\n\nIS ↑\n\nCDC\nIC-L ↑\n\n1.52\n1.97\n1.37\n1.25\n1.97\n1.97\n1.80\n1.55\n1.56\n1.13\n2.10\n1.63\n1.61\n2.05\n1.30\n1.65\n\n0.04\n0.19\n0.06\n0.03\n0.07\n0.05\n0.07\n0.04\n0.06\n0.11\n0.12\n0.06\n0.13\n0.03\n0.05\n0.07\n\nCrop-Paste\nIS ↑ IC-L ↑\n\nSDGAN\nIS ↑ IC-L ↑\n\nDefect-GAN\nIS ↑ IC-L\n\nDFMGAN\nIS ↑ IC-L ↑\n\nAnomalyDiffusion\nIS ↑\nIC-L ↑\n\nIS ↑\n\n1.43\n1.74\n1.23\n1.17\n2.00\n1.74\n1.47\n1.56\n1.49\n1.12\n1.83\n1.30\n1.39\n1.95\n1.23\n1.51\n\n1.57\n1.89\n1.49\n1.18\n1.95\n1.85\n2.04\n1.45\n1.61\n1.17\n2.53\n1.78\n1.76\n2.12\n1.25\n1.71\n\n1.39\n1.70\n1.59\n1.24\n2.01\n1.87\n2.12\n1.47\n1.61\n1.19\n2.35\n1.85\n1.47\n2.19\n1.25\n1.69\n\n1.62\n1.96\n1.59\n1.23\n1.97\n1.93\n2.06\n1.49\n1.63\n1.12\n2.39\n1.82\n1.64\n2.12\n1.29\n1.72\n\n1.58\n2.13\n1.59\n1.16\n2.04\n2.13\n1.94\n1.96\n1.61\n1.28\n2.54\n1.68\n1.57\n2.33\n1.39\n1.80\n\n2.17\n2.15\n1.62\n1.36\n2.13\n1.94\n1.91\n1.57\n1.82\n1.43\n2.40\n2.40\n1.71\n2.24\n2.14\n1.93\n\n0.04\n0.25\n0.05\n0.11\n0.12\n0.21\n0.14\n0.15\n0.11\n0.16\n0.20\n0.08\n0.15\n0.23\n0.11\n0.14\n\n0.06\n0.19\n0.03\n0.11\n0.10\n0.16\n0.12\n0.28\n0.07\n0.10\n0.21\n0.03\n0.13\n0.25\n0.10\n0.13\n\n0.07\n0.22\n0.04\n0.12\n0.12\n0.19\n0.14\n0.30\n0.10\n0.12\n0.22\n0.03\n0.13\n0.29\n0.10\n0.15\n\n0.12\n0.25\n0.11\n0.13\n0.13\n0.24\n0.17\n0.32\n0.16\n0.14\n0.22\n0.18\n0.25\n0.35\n0.27\n0.20\n\n0.19\n0.41\n0.21\n0.24\n0.44\n0.31\n0.41\n0.30\n0.26\n0.30\n0.55\n0.21\n0.34\n0.37\n0.25\n0.32\n\nOurs\nIC-L ↑\n0.43\n0.43\n0.32\n0.29\n0.42\n0.35\n0.35\n0.32\n0.38\n0.36\n0.50\n0.48\n0.33\n0.40\n0.37\n0.38\n\nTable 1. Comparison on IS and IC-LPIPS on MVTec dataset. Our model generates the most high-quality and diverse anomaly data,\nachieving the best IS and IC-LPIPS. Bold and underline represent optimal and sub-optimal results, respectively.\n\nbody from the background by incorporating background information during training, thereby achieving a more stable\ngeneration effect in Fig. 4(b).\n\nMVTec\n\n4. Experiments\n4.1. Experiment Settings\nDataset. We conduct experiments on MVTec [1] and follow\nthe experimental setup of AnomalyDiffusion [14] using 1/3\nof data for training, reserving the remaining 2/3 for testing.\nImplementation Details. We train a model for each\nanomaly type separately and generate 1000 anomaly imagemask pairs for the downstream anomaly inspection tasks.\nMore details of the experiment can be found in the supplementary materials.\nMetric. 1) For generation, we use Inception Score (IS)\nand Intra-cluster pairwise LPIPS distance (IC-LPIPS) [27]\nas AnomalyDiffusion [14] to measure the generation quality\nand generation diversity. 2) For anomaly inspection. We\nuse AUROC, Average Precision (AP), and the F1-max score\nto evaluate the accuracy of anomaly detection and localization, use Accuracy to evaluate the anomaly classification.\n\n4.2. Comparison in Anomaly Generation\nBaseline. 1) We choose CDC [27], Crop-Paste[23],\nSDGAN [26], DefectGAN [47], DFMGAN [6] and AnomalyDiffusion [14] that can generate specific anomaly types\nto compare anomaly generation quality and classification. 2) We select DRAEM[46], PRN [48], DFMGAN [6]\nand AnomalyDiffusion [14] which can generate anomaly\nimage-mask pairs as comparative benchmarks to compare\nanomaly detection and localization.\n\nDefectGAN\n\nDFMGAN\n\nAnomalyDiffusion\n\nOurs\nBottle\nbroken large\n\nCapsule\nsqueeze\n\nGrid\nbent\n\nScrew\nToothbrush\ndefective cratch_head\n\nFigure 5. Comparison of the generation results on MVTec. Our\nmodel excels in generating high-quality anomaly images that are\naccurately aligned with the anomaly masks.\n\nAnomaly Generation Quality. Tab. 1 shows the results\nof the quantification metrics for image quality. For each\nanomaly category, we allocate 1/3 of the anomaly data for\ntraining and generate 1000 anomaly images to compute IS\nand IC-LPIPS. Through this process, it is clearly demonstrated that our method achieves the best results in both the\nIS and IC-LPIPS metrics. Moreover, it further shows that\nour model generates anomaly data with both the highest\nquality and diversity.\n\n\fCategory\n\nDRAEM\nPRN\nDFMGAN\nAnomalyDiffusion\nOurs\nAUC-P AP-P F1 -P AP-I AUC-P AP-P F1 -P AP-I AUC-P AP-P F1 -P AP-I AUC-P AP-P F1 -P AP-I AUC-P AP-P F1 -P AP-I\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nAverage\n\n96.7\n80.3\n76.2\n92.6\n99.1\n98.8\n98.5\n96.9\n95.8\n91.0\n98.5\n93.8\n76.5\n98.8\n93.4\n92.2\n\n80.2 74.0 99.8\n21.8 28.3 83.2\n25.5 32.1 98.7\n43.0 41.9 98.7\n59.3 58.7 99.9\n73.6 68.5 100\n67.6 65.0 100\n84.2 74.5 99.6\n45.3 53.0 98.9\n30.1 35.7 96.3\n93.2 87.8 100\n29.5 28.4 99.8\n31.7 24.2 80.5\n87.8 80.9 100\n65.4 64.7 100\n54.1 53.1 97.0\n\n97.5\n94.5\n95.6\n96.4\n98.9\n98.0\n99.4\n97.9\n98.3\n94.0\n98.5\n96.1\n94.9\n96.2\n98.4\n96.9\n\n76.4 71.3 98.4\n64.4 61.0 92.0\n45.7 47.9 95.8\n69.6 65.6 97.8\n58.6 58.9 98.9\n73.9 68.2 96.0\n58.1 54.0 99.7\n93.0 87.1 99.5\n55.5 72.6 97.8\n47.7 49.8 94.7\n91.8 84.4 96.9\n46.4 46.2 100\n68.6 68.4 88.9\n74.2 67.4 92.7\n79.0 73.7 99.7\n66.2 64.7 96.6\n\n98.9\n97.2\n79.2\n90.6\n75.2\n99.7\n98.5\n99.3\n81.2\n58.8\n99.5\n96.4\n96.2\n95.3\n92.9\n90.0\n\n90.2 83.9 99.8\n81.0 75.4 97.8\n26.0 35.0 98.5\n33.4 38.1 98.5\n14.3 20.5 90.4\n95.2 89.5 100\n68.7 66.7 100\n98.1 94.5 99.8\n67.8 72.6 91.7\n2.2 5.3 64.7\n97.1 91.6 100\n75.9 72.6 100\n81.2 77.0 92.5\n70.7 65.8 99.4\n65.6 64.9 99.9\n62.7 62.1 94.8\n\n99.4\n99.2\n98.8\n98.6\n98.3\n99.8\n99.8\n99.8\n99.8\n97.0\n99.2\n99.2\n99.3\n98.9\n99.4\n99.1\n\n94.1 87.3 99.9\n90.8 83.5 100\n57.2 59.8 99.9\n81.2 74.6 98.8\n52.9 54.6 99.5\n96.5 90.6 99.9\n79.6 71.0 100\n98.7 94.0 100\n97.0 90.8 99.6\n51.8 50.9 97.9\n93.9 86.2 100\n76.5 73.4 100\n92.6 85.7 100\n84.6 74.5 99.4\n86.0 79.2 100\n81.4 76.3 99.7\n\n99.5\n97.5\n99.5\n99.4\n98.5\n99.8\n99.9\n99.6\n99.6\n98.1\n99.7\n98.2\n98.0\n99.4\n99.6\n99.1\n\n93.4 85.7 100\n82.6 76.9 98.3\n73.2 67.0 99.2\n89.1 80.2 99.9\n57.2 54.9 99.7\n97.7 92.8 100\n88.8 78.8 100\n98.0 93.0 99.9\n95.8 89.2 99.0\n57.1 56.1 95.0\n97.1 91.0 100\n68.3 68.6 99.7\n86.7 79.6 93.7\n91.6 83.8 99.9\n90.7 82.7 100\n84.5 78.8 98.9\n\nTable 2. Quantitative result for anomaly detection. Comparison on pixel-level anomaly localization and image-level anomaly detection\non MVTec dataset by training an U-Net on the generated data from DRAEM, PRN, DFMGAN, AnomalyDiffusion and our model.\nCategory DiffAug Crop-Paste DFMGAN AnoDiff Ours\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetalnut\npill\nscrew\ntile\ntransistor\nwood\nzipper\nAverage\n\n48.84\n21.36\n34.67\n35.48\n28.33\n65.28\n40.74\n58.85\n29.86\n25.10\n59.65\n38.09\n41.27\n22.76\n39.31\n\n52.71\n32.81\n32.8\n27.96\n28.33\n59.03\n34.39\n59.89\n26.74\n28.81\n68.42\n41.67\n47.62\n26.42\n40.55\n\n56.59\n45.31\n37.23\n47.31\n40.83\n81.94\n49.73\n64.58\n29.52\n37.45\n74.85\n52.38\n49.21\n27.64\n49.61\n\n90.70\n67.19\n66.67\n58.06\n42.50\n85.42\n61.90\n59.38\n59.38\n48.15\n84.21\n60.71\n71.43\n69.51\n66.09\n\n79.07\n78.12\n70.67\n79.03\n80.0\n89.58\n90.48\n89.06\n56.25\n70.37\n100\n71.43\n85.71\n75.61\n79.67\n\nTable 3. Quantitative result for anomaly classification. Comparison on the classification accuracy(%) trained on the generated\ndata by the anomaly generation models with a ResNet-18. The\nhigher classification accuracy indicates that the generated data is\nmore consistent with the distribution of real data.\n\nMoreover, we present the anomaly images generated by\nseveral prominent anomaly image generation models in Fig.\n5. It is observed that the images generated by Defect-GAN\noften do not have anomalies, DFMGAN tends to introduce\nnoise in the image (bottle, capsule), and the anomaly imagemask pairs lack proper alignment (grid). The state-of-theart model AnomalyDiffusion sometimes generates unreasonable masks outside the objects (grid, screw), and the\ngenerated anomaly does not fit the original image enough to\nmake the anomaly look unreal (toothbrush). In contrast, our\nproposed model demonstrates the ability to generate highly\nrealistic and valid anomalies, even excelling in handling\nsmaller-scale anomalies such as grid-bent. More results are\n\npresented in the supplementary material.\nAnomaly Generation for Anomaly Detection and Localization. We evaluate the effectiveness of our approach by\ncomparing it with existing methods for anomaly generation\nin downstream anomaly detection and localization. We calculate pixel-level dimensions and image-level AUROC, AP,\nand F1-max for each category. The results are presented\nin Tab. 2, and because the image-level results of AUROC,\nAP, and F1-max are relatively similar, as well as the space\nlimitation, we only show the results of the most representative AP, and the other results of AUROC and F1-max are\nshown in the supplementary material. It can be seen that\nthe U-net trained in our generated data reaches the highest\nAP of 84.5% and F1-max of 78.8%, surpassing the secondranked AnomalyDiffusion by a margin of 3.1%(AP).\nAnomaly Generation for Anomaly Classification. To further assess the quality of the anomaly images generated by\nour model, we utilize them to train a downstream anomaly\nclassification model. Following the experimental setup of\nDFMGAN [6], we employ ResNet-18 to train on the generated dataset. We then evaluate the classification accuracy\non our test dataset as shown in Tab. 3. As evident from the\ndata, our model demonstrates significantly higher accuracy\nacross the majority of categories compared to other models,\nwith an average accuracy improvement of 13.58%, indicating the anomaly data we generate is more realistic.\n\n4.3. Comparison with Anomaly Detection Models\nTo further validate the effectiveness of our model, we\ncompare it with state-of-the-art anomaly detection methods\nDRAEM[46], SSPCAB [32], CFA [19], RD4AD [4], PatchCore [36], MuSc [22], DevNet [28], DRA [5] and PRN\n[48]. We utilize their official codes or pre-trained models\n\n\fCategory\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nAverage\n\nDRAEM SSPCAB\n99.1/88.5\n94.8/61.4\n97.6/47.9\n96.3/62.5\n99.5/53.2\n99.5/88.1\n98.8/68.5\n98.7/91.6\n97.7/44.8\n99.7/72.9\n99.4/96.4\n97.3/49.2\n92.2/56.0\n97.6/81.6\n98.6/73.6\n97.7/69.0\n\n98.9/88.6\n93.1/52.1\n90.4/48.7\n92.3/49.1\n99.6/58.2\n99.6/94.5\n97.2/60.3\n99.3/95.1\n96.5/48.1\n99.1/62.0\n99.2/96.3\n97.5/38.9\n85.3/36.5\n97.2/77.1\n98.1/78.2\n96.2/65.5\n\nUnsupervised\nCFA\nRD4AD PatchCore\n98.9/50.9\n98.4/79.8\n98.9/71.1\n99.1/47.7\n98.6/82.9\n98.5/80.2\n96.2/60.9\n98.6/74.6\n98.8/67.9\n98.7/61.4\n98.6/92.6\n98.4/61.7\n98.6/82.9\n97.6/25.6\n95.9/53.9\n98.3/66.3\n\n98.8/51.0\n98.8/77.0\n99.0/60.5\n99.4/46.0\n98.0/75.4\n94.2/57.2\n96.6/53.5\n97.3/53.8\n98.4/58.1\n99.1/51.8\n97.4/78.2\n99.0/63.1\n99.6/50.3\n99.3/39.1\n99.7/52.7\n98.3/57.8\n\n97.6/75.0\n96.8/65.9\n98.6/46.6\n98.7/65.0\n97.2/23.6\n97.6/55.2\n98.9/43.4\n97.5/86.8\n97.0/75.9\n98.7/34.2\n94.9/56.0\n97.6/37.1\n91.8/66.7\n95.7/54.3\n98.5/63.1\n97.1/56.6\n\nSupervised\nDRA\nPRN\n\nMusc\n\nDevNet\n\n98.5/82.8\n96.2/58.8\n98.9/52.7\n99.4/75.3\n98.6/37.0\n99.3/74.4\n99.7/62.6\n87.5/49.6\n97.6/65.6\n98.9/31.7\n98.3/80.6\n99.4/64.2\n92.5/61.2\n98.7/77.5\n98.4/64.2\n97.5/62.6\n\n96.7/67.9\n97.9/67.6\n91.1/46.6\n94.6/19.6\n90.2/44.9\n76.9/46.8\n94.3/66.2\n93.3/57.4\n98.9/79.9\n66.5/21.1\n88.7/63.9\n96.3/52.4\n55.2/4.4\n93.1/47.9\n92.4/53.1\n86.4/49.3\n\n91.7/41.5\n86.1/34.8\n88.5/11.0\n98.2/54.0\n86.2/28.6\n88.8/20.3\n97.2/ 5.1\n80.3/30.6\n79.6/22.1\n51.0/5.1\n91.0/54.4\n74.5/4.8\n79.3/11.2\n82.9/21.0\n96.8/42.3\n84.8/25.7\n\n99.4/92.3\n98.8/78.9\n98.5/62.2\n99.0/82.0\n98.4/45.7\n99.7/93.8\n99.7/69.7\n99.7/98.0\n99.5/91.3\n97.5/44.9\n99.6/96.5\n99.6/78.1\n98.4/85.6\n97.8/82.6\n98.8/77.6\n99.0/78.6\n\nOurs\n99.5/93.4\n97.5/82.6\n99.5/73.2\n99.4/89.1\n98.5/57.2\n99.8/97.7\n99.9/88.8\n99.6/98.0\n99.6/95.8\n98.1/57.1\n99.7/97.1\n98.2/68.3\n98.0/86.7\n99.4/91.6\n99.6/90.7\n99.1/84.5\n\nTable 4. Quantitative result for pixel-level anomaly localization (AUROC/AP). We employ a simple U-Net trained on our generated\ndataset and the existing anomaly detection methods with their official codes or pre-trained models.\nCategory\nbottle\npill\ntoothbrush\nAverage\nMVtec\n\na hazelnut with print\n\na vfx with sks\n\nFigure 6. Comparison of generation results for different prompts\non the hazelnut-print category.\n\nand evaluate them on the same testing dataset (2/3 anomaly\ndata in the test of MVTec). As there is no available opensource code for PRN, we rely on the results provided in its\nresearch paper. The methods are evaluated based on their\npixel-level AUROC and AP scores, as demonstrated in Tab.\n4. It is clearly discernible that upon using the anomaly data\ngenerated by our method, even if only the simplest U-Net\nmodel is utilized, the result shows a significant increase of\n5.9% over that of the traditional method.\n\n4.4. Ablation Study\nFig. 6 presents the results of using different prompts in our\nmodel. It is evident that using the prompt “a vfx with sks”\nyields superior performance in terms of object shape, color,\nand other aspects compared to using the category name directly. The reason is that using real object names and defect\ncategory names as prompt introduces a significant amount\nof prior knowledge. However, the prior knowledge from\nthe natural world may differ greatly from the specific objects and defects in the specific dataset. More quantitative\nresults can be found in the supplementary material.\nFurthermore, we assess the effectiveness of the Back-\n\nWithout BCM\nWith BCM\nAUROC AP F1 -max AUROC AP F1 -max\n98.4\n98.4\n97.2\n98.8\n\n88.8\n86.9\n62.7\n83.0\n\n77.1\n78.2\n64.0\n78.1\n\n99.5\n99.6\n98.2\n99.1\n\n93.4\n95.8\n68.3\n84.5\n\n85.7\n89.2\n68.6\n78.8\n\nTable 5. Comparison on pixel-level anomaly localization on part\nof categories in MVTec between with/without the Background\nCompensation Module. Average is the mean of all categories.\n\nground Compensation Module (BCM), which exhibits more\nnoticeable improvements in the categories of bottle, pill,\nand toothbrush. The visualization results are depicted in\nFig. 4 and the pixel-level localization results are presented\nin Tab. 5. All the qualitative image generation results\nand quantitative metrics are improved significantly by using\nBCM, demonstrating BCM is critical for certain categories.\n\n5. Conclusion\nIn this paper, we present a novel approach, DualAnoDiff,\nfor generating anomalous image-mask pairs. Our method\nemploys a parallel dual-diffusion to simultaneously generate the anomaly image and the corresponding anomaly\npart. This ensures a high level of alignment between the\ngenerated anomaly image-mask pair and the realism of\nthe anomaly image. Additionally, to address challenging\ncases, we introduce a background compensation module\nthat efficiently enhances the model’s fitting capability. Extensive experiments demonstrate its superior performance\ncompared to existing anomaly generation methods. The\nanomaly data generated by our model effectively enhances\nthe performance of downstream anomaly inspection tasks.\n\n\fReferences\n[1] Paul Bergmann, Michael Fauser, David Sattlegger, and\nCarsten Steger. Mvtec ad–a comprehensive real-world\ndataset for unsupervised anomaly detection. In CVPR, pages\n9592–9600, 2019. 2, 6\n[2] Yunkang Cao, Qian Wan, Weiming Shen, and Liang Gao.\nInformative knowledge distillation for image anomaly segmentation. Knowledge-Based Systems, 248:108846, 2022.\n3\n[3] Yunkang Cao, Xiaohao Xu, Chen Sun, Yuqi Cheng, Zongwei\nDu, Liang Gao, and Weiming Shen. Segment any anomaly\nwithout training via hybrid prompt regularization. arXiv\npreprint arXiv:2305.10724, 2023. 3\n[4] Hanqiu Deng and Xingyu Li. Anomaly detection via reverse distillation from one-class embedding. In CVPR, pages\n9737–9746, 2022. 7\n[5] Choubo Ding, Guansong Pang, and Chunhua Shen. Catching\nboth gray and black swans: Open-set supervised anomaly\ndetection. In CVPR, pages 7388–7398, 2022. 7\n[6] Yuxuan Duan, Yan Hong, Li Niu, and Liqing Zhang. Fewshot defect image generation via defect-aware feature manipulation. In AAAI, pages 571–578, 2023. 1, 2, 3, 6, 7\n[7] Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel CohenOr. An image is worth one word: Personalizing text-toimage generation using textual inversion. arXiv preprint\narXiv:2208.01618, 2022. 2, 3\n[8] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing\nXu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and\nYoshua Bengio. Generative adversarial networks. Communications of the ACM, 63(11):139–144, 2020. 3\n[9] Zhihao Gu, Jiangning Zhang, Liang Liu, Xu Chen, Jinlong Peng, Zhenye Gan, Guannan Jiang, Annan Shu, Yabiao\nWang, and Lizhuang Ma. Rethinking reverse distillation\nfor multi-modal anomaly detection. In Proceedings of the\nAAAI Conference on Artificial Intelligence, pages 8445–\n8453, 2024. 3\n[10] Liren He, Zhengkai Jiang, Jinlong Peng, Liang Liu, Qiangang Du, Xiaobin Hu, Wenbing Zhu, Mingmin Chi, Yabiao\nWang, and Chengjie Wang. Learning unified reference representation for unsupervised multi-class anomaly detection.\nIn Proceedings of the European Conference on Computer Vision, 2024. 3\n[11] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner,\nBernhard Nessler, and Sepp Hochreiter. Gans trained by a\ntwo time-scale update rule converge to a local nash equilibrium. NIPS, 30, 2017. 1\n[12] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan AllenZhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen.\nLora: Low-rank adaptation of large language models. arXiv\npreprint arXiv:2106.09685, 2021. 2, 4\n[13] Teng Hu, Jiangning Zhang, Liang Liu, Ran Yi, Siqi Kou,\nHaokun Zhu, Xu Chen, Yabiao Wang, Chengjie Wang, and\nLizhuang Ma. Phasic content fusing diffusion model with\ndirectional distribution consistency for few-shot model adaption. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2406–2415, 2023. 2\n\n[14] Teng Hu, Jiangning Zhang, Ran Yi, Yuzhen Du, Xu Chen,\nLiang Liu, Yabiao Wang, and Chengjie Wang. Anomalydiffusion: Few-shot anomaly image generation with diffusion\nmodel. In Proceedings of the AAAI Conference on Artificial\nIntelligence, pages 8526–8534, 2024. 1, 2, 3, 4, 6\n[15] Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten,\nJaakko Lehtinen, and Timo Aila. Analyzing and improving\nthe image quality of stylegan. In CVPR, pages 8110–8119,\n2020. 3\n[16] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013. 4\n[17] 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. 5\n[18] Joo Chan Lee, Taejune Kim, Eunbyung Park, Simon S Woo,\nand Jong Hwan Ko. Continuous memory representation for\nanomaly detection. In European Conference on Computer\nVision, pages 438–454. Springer, 2024. 3\n[19] Sungwook Lee, Seunghyun Lee, and Byung Cheol Song.\nCfa: Coupled-hypersphere-based feature adaptation for\ntarget-oriented anomaly localization. IEEE Access, 10:\n78446–78454, 2022. 3, 7\n[20] Chun-Liang Li, Kihyuk Sohn, Jinsung Yoon, and Tomas\nPfister. Cutpaste: Self-supervised learning for anomaly detection and localization. In CVPR, pages 9664–9674, 2021.\n2, 3\n[21] Pengzhi Li, Qiang Nie, Ying Chen, Xi Jiang, Kai Wu,\nYuhuan Lin, Yong Liu, Jinlong Peng, Chengjie Wang, and\nFeng Zheng. Tuning-free image customization with image\nand text guidance. In Proceedings of the European Conference on Computer Vision, 2024. 2\n[22] Xurui Li, Ziming Huang, Feng Xue, and Yu Zhou. Musc:\nZero-shot industrial anomaly classification and segmentation\nwith mutual scoring of the unlabeled images. arXiv preprint\narXiv:2401.16753, 2024. 1, 3, 7\n[23] Dongyun Lin, Yanpeng Cao, Wenbin Zhu, and Yiqun Li.\nFew-shot defect segmentation leveraging abundant defectfree training samples through normal background regularization and crop-and-paste operation. In ICME, pages 1–6.\nIEEE, 2021. 2, 3, 6, 1\n[24] Zhikang Liu, Yiming Zhou, Yuansheng Xu, and Zilei Wang.\nSimplenet: A simple network for image anomaly detection\nand localization. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages\n20402–20411, 2023. 3\n[25] Sangwoo Mo, Minsu Cho, and Jinwoo Shin. Freeze the discriminator: a simple baseline for fine-tuning gans. arXiv\npreprint arXiv:2002.10964, 2020. 2\n[26] Shuanlong Niu, Bin Li, Xinggang Wang, and Hui Lin. Defect image sample generation with gan for improving defect\nrecognition. IEEE Transactions on Automation Science and\nEngineering, 17(3):1611–1622, 2020. 2, 3, 6, 1\n[27] Utkarsh Ojha, Yijun Li, Jingwan Lu, Alexei A Efros,\nYong Jae Lee, Eli Shechtman, and Richard Zhang. Fewshot image generation via cross-domain correspondence. In\nCVPR, pages 10743–10752, 2021. 6, 1, 2\n\n\f[28] Guansong Pang, Choubo Ding, Chunhua Shen, and\nAnton van den Hengel.\nExplainable deep few-shot\nanomaly detection with deviation networks. arXiv preprint\narXiv:2108.00462, 2021. 7\n[29] Jinlong Peng, Zekun Luo, Liang Liu, and Boshen Zhang.\nFrih: Fine-grained region-aware image harmonization. In\nProceedings of the AAAI Conference on Artificial Intelligence, pages 4478–4486, 2024. 2\n[30] Xuebin Qin, Zichen Zhang, Chenyang Huang, Masood Dehghan, Osmar R Zaiane, and Martin Jagersand. U2-net: Going deeper with nested u-structure for salient object detection. Pattern recognition, 106:107404, 2020. 5, 1\n[31] 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. 4\n[32] Nicolae-Cătălin Ristea, Neelu Madan, Radu Tudor Ionescu,\nKamal Nasrollahi, Fahad Shahbaz Khan, Thomas B Moeslund, and Mubarak Shah. Self-supervised predictive convolutional attentive block for anomaly detection. In CVPR,\npages 13576–13586, 2022. 7\n[33] Robin Rombach, Andreas Blattmann, Dominik Lorenz,\nPatrick Esser, and Björn Ommer. High-resolution image\nsynthesis with latent diffusion models. In Proceedings of\nthe IEEE/CVF conference on computer vision and pattern\nrecognition, pages 10684–10695, 2022. 2, 4\n[34] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. Unet: Convolutional networks for biomedical image segmentation. In Medical image computing and computer-assisted\nintervention–MICCAI 2015: 18th international conference,\nMunich, Germany, October 5-9, 2015, proceedings, part III\n18, pages 234–241. Springer, 2015. 4\n[35] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. Unet: Convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted\nIntervention–MICCAI 2015: 18th International Conference,\nMunich, Germany, October 5-9, 2015, Proceedings, Part III\n18, pages 234–241. Springer, 2015. 2\n[36] Karsten Roth, Latha Pemula, Joaquin Zepeda, Bernhard\nSchölkopf, Thomas Brox, and Peter Gehler. Towards total recall in industrial anomaly detection. In CVPR, pages\n14318–14328, 2022. 1, 3, 7\n[37] Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch,\nMichael Rubinstein, and Kfir Aberman. Dreambooth: Fine\ntuning text-to-image diffusion models for subject-driven\ngeneration. In CVPR, pages 22500–22510, 2023. 2, 4\n[38] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki\nCheung, Alec Radford, and Xi Chen. Improved techniques\nfor training gans. Advances in neural information processing\nsystems, 29, 2016. 1\n[39] Thomas Schlegl, Philipp Seeböck, Sebastian M Waldstein,\nGeorg Langs, and Ursula Schmidt-Erfurth. f-anogan: Fast\nunsupervised anomaly detection with generative adversarial\nnetworks. Medical image analysis, 54:30–44, 2019. 3\n[40] Chengjie Wang, Chengming Xu, Zhenye Gan, Yuxi Li, Jianlong Hu, Wenbing Zhu, and Lizhuang Ma. Pspu: Enhanced\n\npositive and unlabeled learning by leveraging pseudo supervision. In 2024 IEEE International Conference on Multimedia and Expo (ICME), pages 1–6. IEEE, 2024. 3\n[41] Chengjie Wang, Wenbing Zhu, Bin-Bin Gao, Zhenye Gan,\nJiangning Zhang, Zhihao Gu, Shuguang Qian, Mingang\nChen, and Lizhuang Ma. Real-iad: A real-world multi-view\ndataset for benchmarking versatile industrial anomaly detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 22883–22892,\n2024.\n[42] Chengjie Wang, Xi Jiang, Bin-Bin Gao, Zhenye Gan, Yong\nLiu, Feng Zheng, and Lizhuang Ma. Softpatch+: Fully unsupervised anomaly classification and segmentation. Pattern\nRecognition, 161:111295, 2025. 3\n[43] Jinglong Wang, Xiawei Li, Jing Zhang, Qingyuan Xu, Qin\nZhou, Qian Yu, Lu Sheng, and Dong Xu. Diffusion model is\nsecretly a training-free open vocabulary semantic segmenter.\narXiv preprint arXiv:2309.02773, 2023. 5\n[44] Yue Wang, Jinlong Peng, Jiangning Zhang, Ran Yi, Yabiao\nWang, and Chengjie Wang. Multimodal industrial anomaly\ndetection via hybrid fusion. In Proceedings of the IEEE/CVF\nConference on Computer Vision and Pattern Recognition,\npages 8032–8041, 2023. 3\n[45] Ran Yi, Teng Hu, Mengfei Xia, Yizhe Tang, and Yong-Jin\nLiu. Feditnet++: Few-shot editing of latent semantics in\ngan spaces with correlated attribute disentanglement. IEEE\nTransactions on Pattern Analysis and Machine Intelligence,\n2024. 2\n[46] Vitjan Zavrtanik, Matej Kristan, and Danijel Skočaj. Draema discriminatively trained reconstruction embedding for surface anomaly detection. In ICCV, pages 8330–8339, 2021.\n2, 3, 6, 7\n[47] Gongjie Zhang, Kaiwen Cui, Tzu-Yi Hung, and Shijian Lu.\nDefect-gan: High-fidelity defect synthesis for automated\ndefect inspection. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages\n2524–2534, 2021. 2, 3, 6, 1\n[48] Hui Zhang, Zuxuan Wu, Zheng Wang, Zhineng Chen, and\nYu-Gang Jiang. Prototypical residual networks for anomaly\ndetection and localization. In CVPR, pages 16281–16291,\n2023. 1, 3, 6, 7\n[49] Lvmin Zhang and Maneesh Agrawala. Transparent image\nlayer diffusion using latent transparency. arXiv preprint\narXiv:2402.17113, 2024. 4\n[50] Shengyu Zhao, Zhijian Liu, Ji Lin, Jun-Yan Zhu, and Song\nHan. Differentiable augmentation for data-efficient gan\ntraining. NIPS, 33:7559–7570, 2020. 1\n[51] Jingyuan Zhu, Huimin Ma, Jiansheng Chen, and Jian Yuan.\nHigh-quality and diverse few-shot image generation via\nmasked discrimination. IEEE Transactions on Image Processing, 2024. 2\n\n\fDual-Interrelated Diffusion Model for Few-Shot Anomaly Image Generation\nSupplementary Material\n6. Implementation Details\n\n8. More Qualitative Experiments\n\n6.1. Training Details\n\nWe conducted a comprehensive comparison between our\ngenerated results and those of existing anomaly image generation methods, with the results presented in Fig. 7.\nIt is evident that the diversity of anomalies generated by\nCrop&amp;Paste [23] is limited. The results from DiffAug [50]\nexhibit overfitting. The generated outcomes from CDC\n[27] lack realism, often resulting in distortion, deformation, and other artifacts. SDGAN [26] and Defect-GAN\n[47] fail to generate masks corresponding to the anomalies, and the authenticity of the generated images is also\nlimited. The masks produced by DFMGAN [6] are not sufficiently aligned, often resulting in the generation of spots\nor noise. The currently best-performing method, AnomalyDiffusion [14], solely focuses on learning the anomaly part.\nConsequently, the generated anomaly data fails to integrate\nsmoothly with the original image. And, this sometimes\nleads to the situation where anomalies manifest against the\nbackdrop of the image. In contrast, our method not only\ngenerates highly realistic and diverse anomaly data but also\nproduces highly aligned corresponding masks.\nAmong all these methods, DFMGAN and AnomalyDiffusion are currently the two best performers, so we conducted a more detailed visualization comparison of our results with these two methods. Additional visualizations are\npresented in Fig. 8-14. The left side shows two examples\nfrom the training data, while the right side displays the generated image pairs.\n\nWe train a set of model parameters for each anomaly type.\nThe model requires 5,000 epochs for training, which takes\napproximately 4.5 hours on an NVIDIA V100 32GB GPU.\nWith BCM, the training step requires only 2,000 epochs.\nThe batch size is set to 4, the learning rate is 0.000005, and\nthe rank of LoRA is 32.\nDuring training, we utilize random flipping for data\naugmentation. For the “Background Compensation Module”, we have applied it to all categories that involve backgrounds. Among them, categories bottle, pill and toothbrush have witnessed a highly significant improvement.\nThe improvement in the other several categories is rather\nlimited since they can already be generated with a high level\nof quality.\n\n6.2. Inference Details\nDuring inference without BCM, we only need to input a set\nof prompts: “a vfx with sks” and “sks”. This process generates a set of anomaly images along with the corresponding\nanomaly part images. We generate 1000 image pairs with\na resolution of 512×512 for each anomaly. Specifically, the\nnum inference steps is set to 50, and the guidance scale is\nset to 2.5. Notably, it takes 15 seconds to generate each pair\nof images.\n\n6.3. Mask Generation\nWe employ U2 -Net [30] to segment the anomaly part image\nand obtain the corresponding mask. Based on our observations, this mask is entirely accurate.\n\n7. More Ablation Studies\nWe present comprehensive pixel-level and image-level results for downstream anomaly detection in Tables 6 and 7.\nThe term “dual-interrelated diffusion” refers to the utilization of the dual-interrelated model framework, where the\ntype name such as “cable” is employed as a prompt. The\nnotation “+ prompt” indicates the replacement of the type\nname with “vfx” and “sks”. Additionally, “+BCM” signifies the incorporation of the Background Compensation\nModule, which is specifically applied to the categories of\nbottle, grid, hazelnut, pill, and screw. It can be observed\nthat the prompt we designed outperforms the use of category names, with the exception of the toothbrush category.\nHowever, the gap between the toothbrush category and the\nprompt can be effectively bridged by the BCM module.\n\n9. Quantitative Experiments Setting\n9.1. Generated Data\nIn all comparison methods, 1000 sets of data are generated\nfor each subclass for downstream detection tasks.\n\n9.2. Metrics\nThis section provides supplementary information on the rationale for using these indicators and their definitions.\nFor Generation. General image generation tasks typically\nuse Fréchet Inception Distance (FID) [11] to evaluate the\ndifference between the generated data and the real data distribution. However, FID is not reliable in cases of limited anomalous data, as it tends to produce higher scores\nfor overfitted models. Therefore, we utilize the Inception\nScore (IS) [38] as our evaluation metric. The IS does not\nrequire training data and quantifies the quality and diversity\nof the generated images by calculating the negative exponent of the Kullback-Leibler (KL) divergence between the\n\n\fCategory\n\ndual-interrelated diffusion\nAUC-P AP-P\nF1 -P\n\nAUC-P\n\n+prompt\nAP-P\n\nF1 -P\n\n+prompt +BCM\nAUC-P AP-P F1 -P\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nAverage\n\n96.4\n95.7\n97.8\n99.4\n95.8\n99.5\n98.4\n98.8\n89.6\n97.7\n99.1\n98.2\n94.9\n98.6\n98.4\n97.22\n\n98.4\n97.5\n99.5\n99.4\n98.5\n99.8\n99.9\n99.6\n98.4\n97.7\n99.7\n97.2\n98.0\n99.4\n99.6\n98.8\n\n88.8\n82.6\n73.2\n89.1\n57.2\n96.5\n88.8\n98.0\n86.9\n55.15\n97.1\n62.7\n86.7\n91.6\n90.7\n83.0\n\n77.1\n76.9\n67.0\n80.2\n54.9\n91.5\n78.8\n93.0\n78.2\n72.8\n91.0\n64.0\n79.6\n83.8\n82.7\n78.1\n\n99.5\n97.5\n99.5\n99.4\n98.5\n99.8\n99.9\n99.6\n99.6\n98.1\n99.7\n98.2\n98.0\n99.4\n99.6\n99.1\n\n74.2\n74.1\n54.8\n86.7\n36.2\n94.8\n79.1\n94.4\n38.1\n48.9\n91.0\n65.2\n78.2\n87.3\n82.2\n72.35\n\n69.7\n68.8\n54.3\n77.9\n39.8\n89.9\n70.1\n89.1\n31.2\n47.9\n80.8\n67.1\n73.1\n75.9\n72.5\n67.21\n\n93.4\n82.6\n73.2\n89.1\n57.2\n97.7\n88.8\n98.0\n95.8\n57.1\n97.1\n68.3\n86.7\n91.6\n90.7\n84.5\n\n85.7\n76.9\n67.0\n80.2\n54.9\n92.8\n78.8\n93.0\n89.2\n56.1\n91.0\n68.6\n79.6\n83.8\n82.7\n78.8\n\nTable 6. Ablaiton Study: comparison on pixel-level anomaly localization on the MVTec dataset by training a U-Net on our model’s\ngenerated data using different settings.\nCategory\n\ndual-interrelated diffusion\nAUC-P AP-P\nF1 -P\n\n+prompt\nAUC-I AP-I F1 -I\n\n+prompt +BCM\nAUC-P AP-P F1 -P\n\nbottle\ncable\ncapsule\ncarpet\ngrid\nhazelnut\nleather\nmetal nut\npill\nscrew\ntile\ntoothbrush\ntransistor\nwood\nzipper\nAverage\n\n98.0\n92.3\n81.9\n96.7\n97.2\n100\n100\n97.7\n87.1\n83.5\n100\n97.9\n92.8\n99.3\n100\n94.9\n\n98.7\n97.7\n97.6\n99.8\n99.5\n100\n100\n99.7\n92.0\n86.6\n100\n97.6\n95.1\n100\n100\n97.6\n\n100\n97.7\n97.6\n99.8\n99.5\n100\n100\n99.7\n95.8\n87.8\n100\n99.5\n95.1\n100\n100\n99.8\n\n99.2\n94.5\n93.5\n98.8\n98.6\n100\n100\n99.3\n96.3\n90.1\n100\n98.8\n92.3\n99.7\n100\n97.4\n\n96.4\n85.1\n88.9\n95.7\n95.0\n100\n100\n97.6\n91.2\n84.1\n100\n94.7\n89.4\n97.6\n100\n94.38\n\n98.0\n98.3\n99.2\n99.9\n99.7\n100\n100\n99.9\n97.8\n94.2\n100\n98.5\n93.7\n99.9\n100\n98.6\n\n98.9\n94.2\n95.8\n99.1\n97.6\n100\n100\n99.2\n93.6\n86.1\n100\n93.9\n90.1\n100\n100\n96.5\n\n100\n98.3\n99.2\n99.9\n99.7\n100\n100\n99.9\n99.0\n95.0\n100\n99.7\n93.7\n99.9\n100\n98.9\n\n100\n94.2\n95.8\n99.1\n97.6\n100\n100\n99.2\n95.8\n87.2\n100\n97.5\n90.1\n100\n100\n99.8\n\nTable 7. Ablaiton Study: comparison on image-level anomaly localization on the MVTec dataset by training a U-Net on our model’s\ngenerated data using different settings.\n\nedge distribution of the generated images and the conditional distribution of the class labels predicted by the Inception model. A higher IS score indicates better quality\nand diversity in the generated images.\nIn addition, we use Intra-cluster Pairwise LPIPS Distance (IC-LPIPS) [27] to measure the diversity of the generated data. This method clusters the images into k groups\nbased on the LPIPS distance to k target samples and then\ncomputes the average mean LPIPS distances to the corresponding target samples within each cluster. Higher ICLPIPS scores indicate better diversity.\nFor Anomaly Inspection. We use the Area Under the\n\nReceiver Operating Characteristic (AUROC), Average\nPrecision (AP), and F1 -max to measure the performance\nof the inspection following the general anomaly inspection\ntask.\n\n9.3. Anomaly Inspection Detail\nIn the downstream task of anomaly detection, we employ a\nsimple U-Net [35] architecture. To mitigate the effects of\nrandomness, we train the model three times and select the\nbest result as the final outcome.\n\n\fMVTec\n\nCrop&amp;\nPaste\n\nDiffAug\n\nCDC\n\nSDGAN\n\nDefectGAN\n\nDFMGAN\n\nAnomalyDiffusion\n\nOurs\nBottle\nCable\nbroken large cable_swap\n\nCapsule\nsqueeze\n\nCarpet\ncolor\n\nGrid\nbent\n\nHazel_nut\ncrack\n\nLeather\nfold\n\nMetal_nut\nbent\n\nPill\ncrack\n\nScrew\ncratch_head\n\nTile\noil\n\nToothbrush\ndefective\n\nTransistor\nbent_lead\n\nWood\ncolor\n\nZipper\nfabric_border\n\nFigure 7. Comparison on the generation results on MVTec.\n\nDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\nhazelnut-print\n\nOurs\n\nFigure 8. Comparison on the type of hazelnut-print. DFMGAN and AnomalyDiffusion struggle to generate realistic anomalies, particularly\nin the print class, where the anomalous regions consist of strings of letters. In contrast, our method successfully generates both the shape\nof the letters and the corresponding mask that aligns with their contours.\n\n\fDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\ngrid-broken\n\nOurs\n\nFigure 9. Comparison on the type of grid-broken. For this specific type of small, structure-related anomaly, the images generated by\nDFMGAN are of poor quality, and AnomalyDiffusion fails to produce any anomalies. In contrast, our method generates highly realistic\nand effective anomaly images.\n\nDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\ntoothbrush-defective\n\nOurs\n\nFigure 10. Comparison on the type of toothbrush-defective. The anomalies generated by DFMGAN lack realism, while those produced by\nAnomalyDiffusion are detached from the main object, Additionally, the generated anomalies, such as holes and bristles of toothbrushes,\nare mixed. In contrast, although there are some differences in background color, the generated anomalies by our model are fully consistent\nwith real-world scenarios. Furthermore, the background issues do not impact the effectiveness of anomaly detection in downstream tasks.\n\n\fDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\nleather-poke\n\nOurs\n\nFigure 11. Comparison on the type of leather-poke. The anomalies generated by AnomalyDiffusion are slightly better than those produced\nby DFMGAN, however, there is a noticeable color difference in the leather. In contrast, our method achieves good results in both aspects.\n\nDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\ncapsule-scratch\n\nOurs\n\nFigure 12. Comparison on the type of capsule-scratch. For scratches, a relatively minor type of anomaly, neither DFMGAN nor AnomalyDiffusion can generate effective results. In contrast, our method not only produces realistic anomalies but also demonstrates a good variety.\n\n\fDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\nbottle-broken_small\n\nOurs\n\nFigure 13. Comparison on the type of bottle-broken small. This type of anomaly refers to a small blemish around the edge of a bottle,\nwhile broken large indicates a larger blemish in the same area. The quality of the image generated by DFMGAN is limited, and the mask\nare not properly aligned. while the abnormal position generated by AnomalyDiffusion sometimes is not correct, and the shape does not\nbelong to the type of broken small, but more like broken large. Our method, however, achieves good results in both position and shape.\n\nDFMGAN\n\nAnomaly\nDiffusion\n\nMvtec\ncablecut_inner_insulation\n\nOurs\n\nFigure 14. Comparison on the type of cable-cut inner insulation. It is evident that neither DFMGAN nor AnomalyDiffusion can generate\nrealistic anomalies, and the overall quality of the images produced by DFMGAN is subpar. In contrast, our method successfully generates\nrealistic and diverse abnormal data.\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"