"<!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>Interleaving One-Class and Weakly-Supervised\nModels with Adaptive Thresholding for\nUnsupervised Video Anomaly Detection\nYongwei Nie1 , Hao Huang1 , Chengjiang Long2 , Qing Zhang3 , Pradipta\n\narXiv:2401.13551v2 [cs.CV] 30 Sep 2024\n\nMaji4 , and Hongmin Cai1\n1\n\n⋆\n\nSouth China University of Technology, China\n2\nMeta Reality Labs, USA\n3\nSun Yat-sen University, China\n4\nIndian Statistical Institute, India\n\nAbstract. Video Anomaly Detection (VAD) has been extensively studied under the settings of One-Class Classification (OCC) and WeaklySupervised learning (WS), which however both require laborious humanannotated normal/abnormal labels. In this paper, we study Unsupervised\nVAD (UVAD) that does not depend on any label by combining OCC and\nWS into a unified training framework. Specifically, we extend OCC to\nweighted OCC (wOCC) and propose a wOCC-WS interleaving training\nmodule, where the two models automatically generate pseudo-labels for\neach other. We face two challenges to make the combination effective: (1)\nModels’ performance fluctuates occasionally during the training process\ndue to the inevitable randomness of the pseudo labels. (2) Thresholds are\nneeded to divide pseudo labels, making the training depend on the accuracy of user intervention. For the first problem, we propose to use wOCC\nrequiring soft labels instead of OCC trained with hard zero/one labels, as\nsoft labels exhibit high consistency throughout different training cycles\nwhile hard labels are prone to sudden changes. For the second problem,\nwe repeat the interleaving training module multiple times, during which\nwe propose an adaptive thresholding strategy that can progressively refine a rough threshold to a relatively optimal threshold, which reduces\nthe influence of user interaction. A benefit of employing OCC and WS\nmethods to compose a UVAD method is that we can incorporate the most\nrecent OCC or WS model into our framework. Experiments demonstrate\nthe effectiveness of the proposed UVAD framework. Our code is available\nat https://github.com/benedictstar/Joint-VAD.\nKeywords: Video anomaly detection · One-class classification · Weaklysupervised learning · Unsupervised learning\n\n1\n\nIntroduction\n\nVideo Anomaly Detection (VAD) is a task that identifies abnormal events in a\nvideo, where the abnormal event could be a fire alarm, a flaw in an industrial\n⋆\n\nHongmin Cai is the corresponding author. Email: hmcai@scut.edu.cn\n\n\f2\n\nY. Nie et al.\n\nproduct, or a traffic accident, etc. Most previous VAD methods fall in two categories: One-Class Classification (OCC) methods [12,13,18,19,33,39] and WeaklySupervised (WS) approaches [21, 32, 34, 38, 43, 49]. Both kinds of approaches require human-annotated labels for training 1 . Supervised VAD methods have two\nprominent problems. First, abnormal events are sparse and difficult to recognize,\nmaking the annotation of the training dataset a highly labor-intensive task. Secondly, the categories of abnormal events are unbounded, while human can only\ncollect a limited scope of them, yielding the risk that the trained VAD methods\ncannot handle unobserved abnormal events.\nConsidering the above problems, this paper studies Unsupervised VAD (UVAD)\nthat does not rely on labels. Despite the importance of UVAD, few methods have\nbeen developed except [47] and its subsequent works [2, 37] to the best of our\nknowledge. To achieve unsupervised learning, the method of [47] adversarially\ntrains a generator and a discriminator, where the generator is an autoencoderbased reconstruction model and the discriminator is a fully-connected (FC) binary classifier. While the proposed network architecture is sophisticated, the\nadopted autoencoder and FC networks are relatively weak which limit the performance of the approach.\nIn this paper, we propose a new UVAD framework. Our key idea is that the\ntechniques of OCC and WS approaches are rapidly developed, while a UVAD\nmethod is usually implemented by training two VAD models alternately generating pseudo labels for each other. This motivates us to propose a UVAD\nframework that directly interleaves the training of a pair of OCC and WS models. This allows us to incorporate the recent advances in the two hot research\nfields to implement a UVAD method. We have also attempted to combine two\nOCC or two WS models, but found two homogeneous models are less effective.\nWhile combining OCC and WS methods, we encounter two problems preventing it from effective. First, we observe the OCC or WS model’s performance\nfluctuates occasionally during the training process, which affects the final accuracy they can achieve. This is partly because the pseudo labels generated by\neach other are changed frequently, making the training not stable. To solve this\nproblem, we extend OCC to weighted OCC (wOCC), and propose a wOCC-WS\ninterleaving training module. Previous OCC model is trained on normal data,\nwhile our wOCC model is trained with soft labels in the range of [0, 1]. The\nsoft labels are more consistent across adjacent training cycles, making the performance of wOCC more stable than OCC under changing pseudo labels, thus\nsuppressing the fluctuation effect. Second, we still have to set a threshold to\npartition normal and abnormal pseudo labels for the WS model, making our\nmethod susceptible to a user-provided hyperparameter. To reduce the influence\nof user interaction, we repeat the interleaving training module multiple times,\nduring which we propose an adaptive threshold mechanism that finds an optimal\nthreshold given just a rough initial value from the user.\nTo conclude, the contributions of this work include:\n1\n\nOCC models are trained on normal data only, which requires human labor to exclude\nabnormal events in preparing the training dataset.\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n3\n\n– We propose a new UVAD framework that interleaves the training of a pair\nof OCC and WS models.\n– We improve OCC to wOCC which stabilizes the training of the UVAD framework, and also propose an adaptive thresholding strategy to alleviate the\ninfluence of user interaction.\n– Our UVAD framework is flexible to employ different pairs of OCC and WS\nmodels. Experiments on three OCC and two WS models demonstrate the\neffectiveness of our method.\n\n2\n\nRelated Work\n\nUnsupervised VAD (UVAD). Unsupervised VAD requires identifying anomalies from data containing both normal and abnormal samples without any annotation. This is a challenging new task that is almost unexplored in the literature.\nAlthough significant progress has been made in OCC and WS VAD, directly applying them independently to address UVAD does not yield good results. Zaheer\net al. [47] firstly raise this task and propose to solve UVAD by generative cooperative learning (GCL). Differently, our proposed method modifies both the\nOCC and WS VAD models and combines the modified two models together to\nlearn from unmarked training data.\nOne-Class Classification VAD (OCC). OCC-based VAD approaches\nonly have access to normal data and try to model normal data to identify behaviors that are significantly different from normal behaviors as anomalies. Early\nworks use hand-crafted features to help detect anomalies [5, 23, 40, 51]. With the\nrapid development of deep learning, recent methods turn to normal representations extracted by using a deep neural network [26, 30, 36, 41]. Some methods\nidentify normal patterns by using the reconstruction/prediction model to reconstruct the representations [6,12,14,18,19,24,25,27,31,33,45,46,52]. These models\nmay lead to well-reconstructed anomalies, thereby limiting the performance of\nthe OCC-based methods. Other OCC-based methods turn to identify normal\nrepresentations by using proxy tasks [4, 11, 20, 29, 39]. What’s more, recently,\nHirschorn and Avidan [13] propose to build a multivariate Gaussian distribution for normal data and detect instances deviating from this distribution as\nanomalies. However, the above methods treat all samples equally, ignoring the\npotential differences in importance between normal samples.\nWeakly-Supervised VAD (WS). In weakly-supervised VAD, video-level\nannotations are available in the training stage. Sultani et al [32] first propose\nto use the video-level labels and solve WS VAD based on multi-instance learning (MIL) framework [3, 7]. Since then, many works [21, 28, 38, 43, 49, 50] have\nviewed the WS VAD task as a MIL problem. Tian et al. [34] develop to extend\nMIL to Top-k MIL method by training with a robust temporal feature magnitude\n(RTFM) loss function. The methods mentioned above directly train in the supervision of video-level labels and the coarse-grained supervision limits the accuracy\nof WS models. Recently, two-stage self-training methods [8, 17, 44, 53] adopt a\ntwo-stage pipeline to use more fine-grained labels to supervise the networks more\n\n\f4\n\nY. Nie et al.\n\nFig. 1: Pipeline of our proposed interleaved framework. The wOCC-WS interleaving\ntraining module comprises a weighted OCC (wOCC) model and a WS model, using\nthe output of each model as the pseudo-labels to supervise the other model. Further,\nthe training module is repeated multiple times with the adaptive threshold until the\nstopping criterion we set. To start the first training module, we randomly sample wX\nto train the wOCC model and assign a large value as the threshold for the WS model.\nOnce a training module converges, the last WS model of it supplies wX to start the\nnext training module and adaptive thresholding takes the outputs of all previous wOCC\nmodels into consideration for updating the threshold.\n\nstrictly. The WS model in our framework shares a similar idea with [8] and is\ntailored to use finer-grained snippet-level labels.\n\n3\n\nMethod\n\n3.1\n\nOverview\n\nOur proposed UVAD framework interleaves the training of a pair of OCC and WS\nmodels. In theory, any OCC or WS methods can be incorporated into our framework. Without loss of generality, we take STG-NF [13] (a recent OCC model)\nand RTFM [34] (a recent WS model) as examples to introduce our method in\nthe following sections. We test many other OCC/WS models in Section 4.5.\nFigure 1 shows an overview of our framework. The basic buildingblock of\nour method is the wOCC-WS interleaving training module. In the module, the\noutputs of each model are used as pseudo labels for defining the loss function\ntraining the other model. After one module converges, we re-initialize another\nmodule to run the interleaving training again with a difference that the threshold\nof the WS model is updated by an adaptive threshold adjustment mechanism\nbased on wOCC models trained in previous modules. Since wOCC has more\nstable behaviors than WS, we always initialize the wOCC model to start the\ntraining of a module. For the first module, we use a random initialization based\non Beta distribution sampling. For other modules, we use the results of WS of\nthe preceding module for the initialization.\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n3.2\n\n5\n\nwOCC-WS Interleaving Training Module\n\nWe first introduce the wOCC-WS interleaving training module which comprises\na wOCC model and a WS model. At the very beginning, we initialize the wOCC\nmodel to start the interleaving training. Then, pseudo labels created using wOCC\nare used to train the WS model. Next, pseudo labels created by the WS model\nare used to improve the wOCC model. The whole training does not use human\nannotations.\nwOCC Model (STG-NF). Typically, OCC models are trained only on\nnormal data. Directly using OCC in our UVAD framework may make the training\nfluctuate, i.e., the performance of the trained models sometimes gets better, but\nsometimes worse, finally converging to an inferior point. We use 0 to indicate\nnormal samples, and 1 abnormal samples, where 0, 1 are hard binary labels.\nDuring training, we need to identify 0-labelled samples to train the OCC model.\nThe hard partitioned labels may be suddenly changed from 0 to 1 or from 1 to\n0, yielding the frequent change of the normal samples used to train the OCC\nmodel which is the source of the unstable training. To this end, we propose\nwOCC which relies on soft labels instead of hard binary labels. Soft labels are in\nthe range of [0, 1]. For example, the soft label 0.7 may be changed to 0.6 but not\n0 suddenly. This consistency reduces the fluctuation of the interleaving training.\nTaking STG-NF [13] (an OCC model) as an example, we introduce how to\nimprove it to wOCC. STG-NF extracts a set of objects X = {X1 , · · · , Xi , · · · }\nfrom the training videos, where Xi is a sequence of poses of a person. Each\nobject Xi is the basic building block processed by STG-NF. Originally, STG-NF\nminimizes the negative log-likelihood across the normal data:\n  \\mathcal {L}_{occ} = -log(p_Z(f_{STG-NF}(X_i^+))), \\label {eq: occ-distribution} \n\n(1)\n\nwhere Xi+ ∈ X + is sampled from normal data, Z = fST G−N F (Xi+ ) is the\nfeature extracted from Xi+ by the STG-NF, pZ is the established distribution\nof the normal data. We upgrade STG-NF by introducing the soft labels wX =\n{wX1 , · · · , wXi , · · · } as the weight to supervise its training on both normal and\nabnormal data. Formally, for the wOCC model improved from STG-NF, we\nminimize the following weighted negative log-likelihood across all the data :\n  \\mathcal {L}_{wocc} = -(1-w_{X_i})log(p_Z(f_{STG-NF}(X_i))), \\label {eq: weighted occ-distribution} \n\n(2)\n\nwhere Xi ∈ X is sampled from the whole training dataset rather than the normal\npart and wXi ∈ [0, 1] is the weight of the object Xi indicating the anomaly degree\nof the object which serves as the soft label. The object with smaller wXi means\nmore normal which is better captured by the learned distribution of wOCC.\nPseudo Labels lS from wOCC. Now we use the trained wOCC model\nto generate pseudo labels lS = {lS1 , · · · , lSi , · · · } for training the WS model.\n“Snippet” is the basic element processed by WS models. We first split the training\nvideos into snippets, obtaining a set of snippets S = {S1 , · · · , Si , · · · }. Our aim is\nto compute the label lSi ∈ {0, 1} for each snippet Si . Let xi be the anomaly score\nof the object Xi computed by the trained wOCC model. The anomaly score ŝi\n\n\f6\n\nY. Nie et al.\n\nof a video snippet Si is computed by averaging all the anomaly scores of objects\nin the snippet. To generate pseudo label lSi , one way is to check whether ŝi is\nlarger than a threshold (lSi = 1) or not (lSi = 0). However, as the training goes,\nthe anomaly scores of snippets may vary in a large range, making the absolute\nthreshold invalid. Instead, we sort the snippets according to their anomaly scores\nin descending order, and get the index of the snippet Si by Rank(ŝi ) in the sorted\nlist. Finally, the label lSi of snippet Si is computed by\n  l_{S_i} = \\begin {cases} 1, \\quad {\\rm if} \\quad {\\rm Rank}(\\hat {s}_i) &lt; T_{ws}, \\\\ 0, \\quad {\\rm otherwise}, \\end {cases} \\label {eq:ws-threshold} \n\n(3)\n\nwhere Tws is the relative threshold not affected by concrete anomaly scores.\nWS Model (RTFM). With snippet-level pseudo annotations lS (obtained\nin Eq. 3), we now define positive and negative bags and use them to train a WS\nmodel. Previously, approaches [32,34] usually treat snippets of the same video as\na bag based on video-level labels. Differently, thanks to the snippet-level labels\nprovided by the wOCC model, we can compose positive and negative bags more\nflexibly. In our method, a positive bag B + = {Si+ }C\ni=1 is composed of randomly\nselected C = 16 abnormal snippets. Similarly, a negative bag B − = {Sj− }C\nj=1\nis composed of randomly selected C normal snippets. Taking RTFM [34] as\nan example, the WS method employs multiple instance learning, requiring the\naverage Top-k maximum magnitudes of features in positive bags exceeds that in\nnegative bags:\n  \\begin {split} \\mathcal {L}_{ws} = \\operatorname {max} (0,m- d_{RTFM}(B^+) + d_{RTFM}(B^-)) + \\\\ \\mathcal {L}_{BCE}(B^+) + \\mathcal {L}_{BCE}(B^-), \\label {eq: ws-loss-function} \\end {split} \n\n(4)\n\nwhere m is the margin, and dRT F M (B) (where B can be B + or B − ) returns\nthe average of the Top-k maximum magnitudes of features. Finally, LBCE is the\nbinary cross-entropy-based classification loss:\n  \\mathcal {L}_{BCE}(B)=-Y\\operatorname {log}(f_{RTFM}(B)) +(1-Y)\\operatorname {log}(1-f_{RTFM}(B)), \\label {eq: BCE loss} \n\n(5)\n\nwhere Y is the label of the bag B and fRT F M (B) returns the average of the Topk maximum anomaly scores. Note that fRT F M (B) is different from dRT F M (B),\nwhere fRT F M (B) returns the anomaly scores while dRT F M (B) returns the magnitude of the features.\nPseudo Labels wX from WS. wOCC model needs soft labels wX . With\nthe trained WS model, we compute the anomaly score x̂i of object Xi by simply\nsetting it as the anomaly score of the snippet containing the object Xi . Then,\nthe soft label wXi is directly set as:\n  w_{X_i} = \\hat {x}_i. \\label {eq:compute_weights} \n\n(6)\n\nx̂i is already in the range of [0, 1], so we do not need to normalize wXi .\nInitializing the Interleaving Training Module. As discussed above, in\nour proposed interleaving training module, wOCC training relies on pseudo labels generated by the WS model, and conversely, WS training requires pseudo\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n7\n\nlabels derived from the wOCC. This egg and chicken problem needs to be solved\nat the very beginning. Our solution is to provide the wOCC model with randomly generated soft labels to start the interleaving training. Usually, the training dataset contains much more normal samples than abnormal ones, which\nmeans most soft labels are around 0 while a small portion of them are near 1.\nTherefore, we randomly sample the weight wX from the Beta distribution, i.e.,\nwX ∼ Beta(α, β), where α = 1 and β = 5. The sampled weights wX are mostly\naround 0, and a small portion of them is close to 1, satisfying the prior about\nthe distribution of normal and abnormal data.\nConvergence Analysis. We have discussed the mechanism and the way to\nstart the interleaving training module above. Then, in the following, we empirically analyze its convergence, which is validated by the experiment in Figure 6.\nAt the very beginning, we randomly initialize the weight wX to train our wOCC\nmodel. Although the random initialization is not precise, the wOCC model can\nstill learn normal patterns from the training data, as we assume there is more\nnormal data than abnormal data in the training dataset. Therefore, the wOCC\nmodel can produce relatively reliable pseudo labels for the WS model. This is\nvery important as the WS model has a high requirement on the quality of the\npseudo labels. In turn, with the trained WS model, we can provide better pseudo\nsupervision to train a stronger wOCC model than the random initialization. In\nthis way, we achieve mutual improvement between two models until convergence.\nThe above analysis implies the reason why we do not choose to interleave the\ntraining of two OCC models or two WS models. The OCC model can provide\nreliable initialization, while the WS model explicitly enlarges the gap between\nnormal and abnormal samples. Two OCC models fail to utilize the abnormal\ndata, while for two WS models it is not known how to provide a reliable initialization to start the training.\n3.3\n\nRepeating Procedure with Adaptive Thresholding\n\nIn the above, the wOCC and WS models need to provide pseudo labels to supervise the other. As the wOCC model relies on soft labels wX as defined in\nEq. 6, its pseudo labels can be directly provided by the WS model without\nthresholding. However, as defined in Eq. 3, we need to specify a threshold for\nthe WS model since it requires binary hard partition labels to construct positive\nand negative bags. To alleviate the influence of human interaction, we propose\na repeating procedure of the interleaving training module which can adaptively\nrefine a user-specified rough threshold to a relatively optimal one.\nStarting and running the next interleaving training module. As\nshown in Figure 1, we run several interleaving training modules one after another.\nRecall that we provide wX by random initialization to start the first interleaving\ntraining module as discussed in Section 3.2. To start the next module, we use the\nfinal WS model in the last module to provide the labels wX . For the wOCC and\nWS models in a new interleaving training module, we train them from scratch,\nnot inheriting parameters from the last module.\n\n\f8\n\nY. Nie et al.\n\nAdaptive Thresholding. The threshold is fixed in each module. Between\ntwo modules, we employ an adaptive thresholding mechanism to refine the\nthreshold. As the repeating procedure runs, we obtain a series of thresholds\n1\n2\ni\n{Tws\n, Tws\n, · · · , Tws\n, · · · } corresponding to the interleaving training modules. The\nkey idea of adaptive thresholding is to ensure:\n  T_{ws}^1\\geq T_{ws}^2\\geq \\cdots \\geq T_{ws}^i\\geq \\cdots . \\label {eq:threshold_requirement} \n\n(7)\n\n1\nStarting from a sufficiently large (larger than the optimal threshold) value of Tws\n,\n∗\n1\n2\ni\nthere must be one threshold Tws\n∈ {Tws\n, Tws\n, · · · , Tws\n, · · · } that is closest to the\noptimal threshold. The problem is how to enforce the monotonically decreasing\nof the threshold and how to stop the repeating procedure at the optimal point.\n1\nFirst, we initialize Tws\n= R%×N , where R is a user-specific hyper-parameter,\ne.g. R = 30, and N is the total number of snippets in the training dataset. This\n1\na large enough threshold, since generally the ratio of abnormal\nsetting makes Tws\ndata in the training dataset is less than 30%. We test different R (e.g., 35%) in\nthe experimental section and find that it does not influence our final results\nmuch, demonstrating the robustness of our method to the user interaction.\nThen, to ensure Eq. 7, our adaptive thresholding method determines the\nthreshold used in the current module based on wOCC models trained in all\nprevious modules. Each training module produces multiple wOCC models, obtaining one after each loop between wOCC and WS. Let Mi be the number of\ni+1\nfor\nwOCC models trained from module 1 to module i. When computing Tws\nmodule i + 1 with i ≥ 1, we take all the Mi wOCC models into consideration.\nSpecifically, for each wOCC, e.g., the j th one where j ∈ [1, Mi ], we use it to identify R% of snippets in the training dataset that have high anomaly scores, and\ndenote the resulting set of snippets as Aj . We then compute intersection between\nall sets and count the number of the resulting intersection as the threshold:\n\n  T^{i+1}_{ws} = {\\rm Num}(A_1\\cap A_2\\cap \\cdots \\cap A_{M_i}), \\label {eq:G-i} \n\n(8)\n\nwhere Num(·) counts the number of elements in the intersection. The operation\nof computing intersection ensures that the obtained threshold is monotonically\ndecreased. In essence, the threshold computed in this way means the number\nof snippets viewed as abnormal by all wOCC models. At the early stages, the\nnumber of wOCC models is small, therefore the size of the intersection is large,\nyielding large thresholds. As more wOCC models involved, it is more difficult to\nform a consensus, thus producing smaller thresholds.\nTo elucidate the effect of the adaptive thresholding, we visualize how WS\nmodels are gradually improved as the repeating procedure runs in Figure 2. In\nthe figure, we show two examples. Taking the one on the left as an example, it\nshows a video with an abnormal event in the middle. At the beginning when\nTws = 1643, the WS model wrongly identifies the abnormal event as normal. As\nthe repeating procedure runs, Tws becomes smaller and smaller, which is finally\nreduced to 834 after repeating 5 times, and the WS model begins to identify the\nanomaly event progressively.\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n9\n\nFig. 2: As repeating procedure goes, Tws monotonically decreases, improving the WS\nmodel gradually. Left: example from ShanghaiTech. Right: example from UBnormal.\n∗\nStopping Criterion. As our goal is to find the threshold Tws\nclose to the\noptimal threshold, we need to stop the repeating procedure at the right time.\nExperimentally, we find that Tws drops fast at the first few interleaving training\nmodules, then the rate of change of Tws becomes smaller which indicates that\nthe wOCCs achieve a consensus about anomalies. The size of the consensus set is\nprobably the actual number of abnormal snippets in the dataset. Based on this\nobservation, once change rate of Tws between two consecutive training modules is\nless than Q% of the first change rate at the very beginning, we stop the repeating\nprocedure. Please see the high correlation between the change rate of Tws and\nthe accuracy of the WS model in Figure 4.\nTraining Time Analysis. Though we need to repeat the interleaving training module multiple times, our training is as fast as the original wOCC or WS\nmethod. First, the repeating procedure usually stops with fewer than 6 modules\nthanks to the stopping criterion. Furthermore, we train wOCC (or WS) for just\none epoch, and then exchange to train WS (or wOCC) for another epoch. If we\nhave 6 modules, each running an average of 5 loops of interleaving training, the\nwOCC and WS models are trained for just 30 epochs each. The original wOCC\nor WS models are also trained for the similar number of epochs in their default\nexperimental settings. The detailed experiments are in Section 4.5.\n\n3.4\n\nInference\n\nAt the inference stage, both wOCC and WS models can be used to detect anomalies. We provide results of both models when compared with previous methods.\n\n4\n\nExperiments\n\n4.1\n\nDatasets and Evaluation Metrics\n\nShanghaiTech.The ShanghaiTech dataset [18] contains 437 videos and was created as a benchmark for OCC with only normal videos available in the training\n\n\f10\n\nY. Nie et al.\n\nset. Zhong et al. [53] reorganized the dataset to enable the training of WS systems. The new split contains 63 abnormal videos and 175 normal videos, while\nthere are 44 anomalous and 155 normal videos in the new testing split. In our\nunsupervised setting, we follow the split for WS approaches but do not provide\nvideo-level annotations in the training stage.\nUBnormal.The UBnormal dataset [1] is a synthetic open-set benchmark,\ncontaining 268 training videos, 64 validation videos and 211 test videos. Normal\nand abnormal videos are mixed in the three subsets. The dataset is challenging\nbecause of disjoint sets of anomaly types in training and testing sets. We follow\nits original organization but train our proposed UVAD without any annotations.\nEvaluation Metrics. Following prior VAD arts [13, 34], we use the framelevel area under ROC curve (AUC) to measure VAD’s accuracy for both datasets.\n4.2\n\nwOCC and WS models Employed\n\nAs stated, our method is a flexible UVAD framework that can use different\nwOCC and WS models. We test improving three OCC models to wOCC, including the AE model used in [47], Jigsaw [39], and STG-NF [13]. The wOCC\nlosses for AE and Jigsaw are put into supplemental material.\n(1) AE. GCL [47] proposes to use an AutoEncoder that reconstructs the\nfeatures extracted from videos as their OCC model. We use it here too.\n(2) Jigsaw. The OCC model Jigsaw [39] addresses VAD by solving a pretext\ntask: spatio-temporal jigsaw puzzles. It divides the spatio-temporal space of a\nvideo into smaller cubes, then shuffles the positions of the cubes, and finally tries\nto restore the original positions of the cubes.\n(3) STG-NF. STG-NF [13] extracts people’s pose sequences, and extends\nGlow [16] to build multivariate Gaussian distribution of normal action sequences.\nFor WS, we test the method proposed in Sultani et al. [32] and RTFM [34].\n(1) Sultani et al. [32]. Sultani et al. [32] propose the first MIL VAD model\nthat maximizes the separability between a positive bag containing snippets of\nan abnormal video and a negative bag with snippets of a normal video.\n(2) RTFM. RTFM [34] extends Sultani et al. [32] to compare the Top-k\nlargest-magnitude snippets between positive and negative bags.\n4.3\n\nImplementation Details\n\nWe implement our method in PyTorch. For STG-NF and RTFM (implementation details of other wOCC/WS models are put in supplemental material), they\nare optimized by Adam optimizer with β1 = 0.9, β2 = 0.999, and a weight decay\nof 0.0005. The batch size of STG-NF is 256, and that of RTFM is 32. The learning rate is 5e − 4 and 1e − 3 for STG-NF and RTFM respectively. For RTFM,\nthe margin m is set to 100. During interleaving training, we train a model for\none epoch and then exchange to train the other model for another epoch.\nOur method has two hyperparameters shared by all types of wOCC or WS\n1\nmodels. One is R% which determines the initial threshold Tws\n. By default, we set\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n11\n\nTable 1: Comparison with previous approaches. For wOCC, we use STG-NF [13].\nFor WS, we use RTFM [34]. We test using C3D [35] and I3D [15] to extract features\nfor RTFM. OurwOCC gives the AUC of the wOCC model. OurW S gives the AUC of\nthe WS model. The methods split by the dashed line are trained as a whole in our\nframework. * means we reimplement the method by taking I3D as the feature. **\nmeans our method degenerated to the supervised OCC or WS method. *** means the\nresults are reproduced by us using the official code.\nOne-Class Classification\nWeakly Supervised\nUnsupervised\nSTech\nUB\nSTech\nUB\nSTech\nUB\nMethod\nMethod\nFeatures\nFeatures\nAUC % AUC %\nAUC % AUC %\nAUC % AUC %\nMemAE [12]\n71.20\nGCN [53]\nC3D\n76.44\nI3D\n60.51\nAEAllData\nFrame Prediction [18] 73.40\nGCN [53]\nTSN\n84.44\nMarkovitz et al. [22]\n76.10\n52.00 Zhang et al. [50]\nC3D\n82.50\n80.29\n70.48\nSTG-NFAllData [13]\n2\n∗∗∗\nHF -VAD [19]\n76.20\nSultani et al.\n[32] I3D\n84.53\n54.12\nI3D\n76.14\nGCL∗ [47]\nCT-D2GAN [9]\n77.70\nAR-Net [38]\nI3D\n85.38\nCAC [42]\n79.30\nCLAWS [48]\nC3D\n89.67\n81.50\n71.67\nOurwOCC\nSSMTL [10]\n82.40\nMIST [8]\nI3D\n94.83\nGeorgescu et al. [11]\n82.70\n59.30 Li et al. [17]\nI3D\n96.08\nC3D\n85.43\n59.05\nOurW S\nSSMTL++ [4]\n83.80\n62.10 RTFM∗∗∗ [34]\nC3D\n91.51\n62.30\n84.30\n56.40 RTFM∗∗∗ [34]\nI3D\n96.10\n66.83\n82.57\n74.76 Jigsaw [39]\nOurwOCC\nSTG-NF [13]\n85.90\n71.80 S3R [43]\nI3D\n97.48\nI3D\n88.18\n63.10\nOurW S\n86.37 72.81 Our∗∗\nI3D\n96.33\n67.42\nOur∗∗\nwOCC (STG-NF)\nW S (RTFM)\nMethod\n\nTable 2: Ablation study on wOCC im- Table 3: Ablation study on using difproved from different OCC models, always ferent WS models in our method, always\nwith RTFM as the WS model.\nwith STG-NF as the wOCC model.\nOCC Model OurwOCC OurW S (RT F M ) GCLClassif ier\nAE\n70.99\n78.90\n76.14\nJigsaw [39]\n81.23\n85.35\nSTG-NF [13] 82.57\n88.18\n-\n\nWS Model\n\nOurwOCC (STG-NF) OurW S\n\nSultani et al. [32]\n\n81.92\n\n77.41\n\nRTFM [34]\n\n82.57\n\n88.18\n\nit to 15% for the ShanghaiTech dataset which contains a small ratio of abnormal\ndata. The UBnormal dataset contains relatively more abnormal data and we set\nR% to 30%. The other parameter is Q% used to stop the repeating procedure.\nFor both datasets, we set Q% to 10%. Analysis of Q% is put into Supp.\n4.4\n\nComparison with Previous Approaches\n\nFrom left to right, Table 1 shows the comparison between our and previous approaches under Unsupervised, One-Class Classification and Weakly-Supervised.\nSince the unsupervised methods are scarce, besides GCL [47], we compare with\nAEAllData which means training the AE model on the whole training dataset containing both normal and abnormal data. We also compare with STG-NFAllData .\nFor our method, we adopt STG-NF [13] as wOCC, and RTFM [34] as WS.\nFirst, OurwOCC (trained along with RTFM (I3D)) outperforms STG-NFAllData\n(see the table on the left). This validates the benefit of using our method to\ndistinguish the normal from abnormal data in the training dataset. On ShanghaiTech, our proposed wOCC improves STG-NF from 80.29% to 82.57%. In\ncontrast, the improvement is from 70.48% to 74.76% on UBnormal. The improvement on UBnormal is larger as there is more abnormal data in UBnormal\nwhich causes STG-NFAllData to perform worse.\n\n\f12\n\nY. Nie et al.\nTable 4: Comparison with fixed thresholding.\nWeighted OCC\n✗\n✓\n✗\n✓\n\nWS with Adaptive Threshold\n✗\n✗\n✓\n✓\n\nRTFM (AUC %)\n82.06\n83.48\n85.86\n88.18\n\nSTG-NF (AUC %)\n80.52\n81.78\n81.94\n82.57\n\nSecond, please compare our method with GCL. OurW S achieves an AUC of\n88.18%, while that of GCL is 76.14% (this score is reported by the classifier\nof GCL, thus we use our WS model for the comparison). This significant improvement is partly due to the reason that we use a stronger OCC model, i.e.,\nSTG-NF, than GCL. If using the same OCC model, our method outperforms\nGCL by 2.76%, as shown in Table 2.\nOur UVAD method can be degenerated into a supervised OCC method. For\nexample, we can perform our interleaving training on the normal data only. The\nobtained wOCC model in this setting is denoted by Our∗∗\nwOCC which outperforms existing supervised OCC approaches (see the table in the middle). This\nvalidates the effectiveness of the proposed wOCC with weighted importance, as\neven among the normal data there is data that is more normal than other data,\nand the wOCC model can better identify their difference.\nTo degenerate our method into a supervised WS method, we allow our WS\nmodel to know video-level labels. Specifically, snippets of normal videos are\ntreated as normal. Since snippets of abnormal videos can be either normal or\nabnormal, they are processed by our adaptive thresholding approach. As seen in\nTable 1 on the right, Our∗∗\nW S (RTFM) outperforms the baseline RTFM [34]. On\nUBnormal, our method performs best among all the compared WS methods.\n4.5\n\nAblation Study and Discussions\n\nNext, we perform ablation studies on our method. Without extra explanations,\nexperiments are conducted by taking STG-NF as wOCC and RTFM as WS.\nComparison between OCC over wOCC. In Figure 3, we compare the\nperformance fluctuation of using wOCC or OCC (STG-NF) in our framework\nin the first two interleaving training modules’ training. As shown, directly using\nOCC leads to performance fluctuation of both OCC and WS models and converges to an unsatisfactory point. In comparison, our proposed wOCC stabilizes\nthe training and improves the performance of both models.\nUsing Different OCC/WS Models. In Table 2, we conduct experiments\nof upgrading different types of OCC models to wOCC in our method. We test\nAE [47], Jigsaw [39], and STG-NF [13], while always using RTFM [34] as the WS\nmodel. As seen, the effectiveness of our method is essentially affected by wOCC\nmodel. Similarly in Table 3, the same wOCC model is used but with different\nWS models. Overall, a better wOCC or WS model yields better results.\nComparison with Fixed Thresholding. In Table 4, the first row shows\nresults of using fixed thresholding for both OCC and WS models. The second and\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n13\n\nFig. 3: Performance fluctuation in the first Fig. 4: Left: ShanghaiTech. Right: UBnorand second modules. Red line: AUC of mal. Top: Tws in each interleaving trainwOCC (or WS) when interleaving wOCC ing module. Bottom: The AUC of the WS\nand WS. Blue line: AUC of OCC (or WS) model in each module. Stars in top figures:\nposition where achieves stopping criterion.\nwhen interleaving OCC and WS.\nTable 5: Training time on ShanghaiTech.\nModel\nOur UVAD\nSTG-NF [13]\nRTFM [34]\n\nEpoch\nEach Step\n1\n2\n3\n-\n\nTraining\nSteps\n17\n12\n11\n-\n\nTraining\nEpochs\n2×1×17\n2×2×12\n2×3×11\n8\n50\n\nTraining\nTime\n2h28m\n2h42m\n3h31m\n10m\n2h32m\n\nSTG-NF\nAUC %\n82.57\n82.53\n82.27\n85.90\n-\n\nRTFM\nAUC %\n88.18\n87.95\n86.36\n97.21\n\nthird rows use fixed thresholding for either OCC or WS models. The fourth row\nshows our method with wOCC and adaptive thresholding. As seen, our method\noutperforms all the other variants.\nEffectiveness of the Stopping Criterion. In Figure 4, we show that with\nthe current stopping criterion, our method can stop when it achieves the best\nAUC (i.e., the best VAD accuracy). As the repeating procedure runs, Tws drops\nand AUC increases. Tws drops very fast at the very beginning, and then the drop\nrate becomes slower. Simultaneously, AUC first increases and then decreases. We\nstop our method when the change rate of Tws is about 10% of its original change\nrate, which finds the best stopping positions indicated by the stars in top figures.\nRobustness to R%. Our method is robust to the parameter R%, as demonstrated in Figure 5. On the top, we show that the threshold Tws converges to\nsimilar values after 6 interleaving training modules when using different R%.\nAt the bottom, we show that different R% yield similar AUC on both training\ndatasets. The experiments demonstrate that our method is not influenced much\nby this parameter for each dataset. For different datasets, we need to set different\nR% that roughly match with the ratio of anomaly data in the datasets.\nTraining Loss Curve. In Figure 6, we show training loss curves of the\nwOCC (STG-NF) model in our framework. As seen, the loss drops smoothly\nwithin each interleaving training module. Since we re-train the wOCC model\nfrom scratch in the next module, the loss suddenly increases at the beginning of\nthe next module, but the peak magnitude of the loss is lower than that of the\nprevious module. Please check the zoomed-in curve showing the loss curve of the\n\n\f14\n\nY. Nie et al.\n\nFig. 5: Top: different R% converge to Fig. 6: Bottom: training loss curve of the\nsimilar Tws (on ShanghaiTech). Bottom: wOCC model during the whole repeating\ndifferent R% yield similar AUC (Left: on procedure. Top: zoomed-in training loss\ncurve in the third module.\nShanghaiTech, Right: on UBnormal).\n\nwOCC model in the third module. Even though the model is trained alternately\nwith another model, its loss can still decrease smoothly, not affected by the other\nmodel. The WS model’s training loss curve is put into the supplemental material.\nTraining Time. As mentioned in Section 3.3, although we need to train the\nwOCC and WS models alternately many times in multiple modules, our method\nis fast in training. That is because, we just train a model for one epoch and\nthen exchange to train the other model for another epoch, which form a training\nstep of our method. Our interleaving training converges very fast. As shown in\nTable 5, there are only 17 training steps during the whole training, yielding a\ntotal of 34=2(wOCC and WS)×1(epoch)×17(all training steps) epochs. It takes\naround 2.5 hours to train our method on ShanghaiTech. We have also trained\nthe wOCC or WS model for 2 or 3 epochs in each training step, but obtained\nworse results, probably because training with more epochs would enhance the\nsupervision of wrong pseudo labels in early training modules.\n\n5\n\nConclusion\n\nIn this paper, we interleave the One-Classification and Weakly-Supervised models with adaptive thresholding to tackle the unsupervised video anomaly detection problem without human annotation. We face the challenges of performance\nfluctuation and the demanding of accurate threshold when designing the framework. To alleviate performance fluctuation, We propose the wOCC model which\nrequires soft labels but not binary labels. To obtain a relative optimal threshold,\nwe repeat our proposed interleaving training module, during which we propose a\nmonotonically threshold decreasing mechanism to refine a rough threshold progressively. Extensive experiments demonstrate the effectiveness of our method.\nRemarkably, our method can be upgraded with the most recent development in\nOCC and WS VAD fields.\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n15\n\nAcknowledgements\nThis work was partly supported by the Natural Science Foundation of China\n(62072191, U21A20520, 62325204), the National Key Research and Development\nProgram of China (2022YFE0112200), the Key-Area Research and Development\nProgram of Guangzhou City (202206030009), and the Guangdong Basic and\nApplied Basic Research Fund (2023A1515030002, 2024A1515011995).\n\nReferences\n1. Acsintoae, A., Florescu, A., Georgescu, M., Mare, T., Sumedrea, P., Ionescu, R.T.,\nKhan, F.S., Shah, M.: Ubnormal: New benchmark for supervised open-set video\nanomaly detection. In: Proceedings of the IEEE/CVF Conference on Computer\nVision and Pattern Recognition (CVPR) (June 2022)\n2. Al-lahham, A., Tastan, N., Zaheer, M.Z., Nandakumar, K.: A coarse-to-fine pseudolabeling (c2fpl) framework for unsupervised video anomaly detection. In: Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision.\npp. 6793–6802 (2024)\n3. Andrews, S., Tsochantaridis, I., Hofmann, T.: Support vector machines for\nmultiple-instance learning. Advances in neural information processing systems 15\n(2002)\n4. Barbalau, A., Ionescu, R.T., Georgescu, M.I., Dueholm, J., Ramachandra, B.,\nNasrollahi, K., Khan, F.S., Moeslund, T.B., Shah, M.: Ssmtl++: Revisiting selfsupervised multi-task learning for video anomaly detection. Computer Vision and\nImage Understanding 229, 103656 (2023)\n5. Basharat, A., Gritai, A., Shah, M.: Learning object motion patterns for anomaly\ndetection and improved object detection. In: 2008 IEEE conference on computer\nvision and pattern recognition. pp. 1–8. IEEE (2008)\n6. Burlina, P., Joshi, N., Wang, I., et al.: Where’s wally now? deep generative and\ndiscriminative embeddings for novelty detection. In: Proceedings of the IEEE/CVF\nconference on computer vision and pattern recognition. pp. 11507–11516 (2019)\n7. Dietterich, T.G., Lathrop, R.H., Lozano-Pérez, T.: Solving the multiple instance\nproblem with axis-parallel rectangles. Artificial intelligence 89(1-2), 31–71 (1997)\n8. Feng, J.C., Hong, F.T., Zheng, W.S.: Mist: Multiple instance self-training framework for video anomaly detection. In: Proceedings of the IEEE/CVF conference\non computer vision and pattern recognition. pp. 14009–14018 (2021)\n9. Feng, X., Song, D., Chen, Y., Chen, Z., Ni, J., Chen, H.: Convolutional transformer\nbased dual discriminator generative adversarial networks for video anomaly detection. In: Proceedings of the 29th ACM International Conference on Multimedia.\npp. 5546–5554 (2021)\n10. Georgescu, M.I., Barbalau, A., Ionescu, R.T., Khan, F.S., Popescu, M., Shah, M.:\nAnomaly detection in video via self-supervised and multi-task learning. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition.\npp. 12742–12752 (2021)\n11. Georgescu, M.I., Ionescu, R.T., Khan, F.S., Popescu, M., Shah, M.: A backgroundagnostic framework with adversarial training for abnormal event detection in video.\nIEEE transactions on pattern analysis and machine intelligence 44(9), 4505–4523\n(2021)\n\n\f16\n\nY. Nie et al.\n\n12. Gong, D., Liu, L., Le, V., Saha, B., Mansour, M.R., Venkatesh, S., Hengel, A.v.d.:\nMemorizing normality to detect anomaly: Memory-augmented deep autoencoder\nfor unsupervised anomaly detection. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 1705–1714 (2019)\n13. Hirschorn, O., Avidan, S.: Normalizing flows for human pose anomaly detection.\nIn: Proceedings of the IEEE/CVF International Conference on Computer Vision.\npp. 13545–13554 (2023)\n14. Ionescu, R.T., Khan, F.S., Georgescu, M.I., Shao, L.: Object-centric auto-encoders\nand dummy anomalies for abnormal event detection in video. In: Proceedings of the\nIEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 7842–\n7851 (2019)\n15. Kay, W., Carreira, J., Simonyan, K., Zhang, B., Hillier, C., Vijayanarasimhan, S.,\nViola, F., Green, T., Back, T., Natsev, P., et al.: The kinetics human action video\ndataset. arXiv preprint arXiv:1705.06950 (2017)\n16. Kingma, D.P., Dhariwal, P.: Glow: Generative flow with invertible 1x1 convolutions. Advances in neural information processing systems 31 (2018)\n17. Li, S., Liu, F., Jiao, L.: Self-training multi-sequence learning with transformer for\nweakly supervised video anomaly detection. In: Proceedings of the AAAI Conference on Artificial Intelligence. vol. 36, pp. 1395–1403 (2022)\n18. Liu, W., Luo, W., Lian, D., Gao, S.: Future frame prediction for anomaly detection–\na new baseline. In: Proceedings of the IEEE conference on computer vision and\npattern recognition. pp. 6536–6545 (2018)\n19. Liu, Z., Nie, Y., Long, C., Zhang, Q., Li, G.: A hybrid video anomaly detection\nframework via memory-augmented flow reconstruction and flow-guided frame prediction. In: Proceedings of the IEEE/CVF international conference on computer\nvision. pp. 13588–13597 (2021)\n20. Lorre, G., Rabarisoa, J., Orcesi, A., Ainouz, S., Canu, S.: Temporal contrastive\npretraining for video action recognition. In: Proceedings of the IEEE/CVF winter\nconference on applications of computer vision. pp. 662–670 (2020)\n21. Lv, H., Yue, Z., Sun, Q., Luo, B., Cui, Z., Zhang, H.: Unbiased multiple instance\nlearning for weakly supervised video anomaly detection. In: Proceedings of the\nIEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR).\npp. 8022–8031 (June 2023)\n22. Markovitz, A., Sharir, G., Friedman, I., Zelnik-Manor, L., Avidan, S.: Graph embedded pose clustering for anomaly detection. In: Proceedings of the IEEE/CVF\nConference on Computer Vision and Pattern Recognition. pp. 10539–10547 (2020)\n23. Medioni, G., Cohen, I., Brémond, F., Hongeng, S., Nevatia, R.: Event detection and\nanalysis from video streams. IEEE Transactions on pattern analysis and machine\nintelligence 23(8), 873–889 (2001)\n24. Morais, R., Le, V., Tran, T., Saha, B., Mansour, M., Venkatesh, S.: Learning\nregularity in skeleton trajectories for anomaly detection in videos. In: Proceedings\nof the IEEE/CVF conference on computer vision and pattern recognition. pp.\n11996–12004 (2019)\n25. Nguyen, T.N., Meunier, J.: Anomaly detection in video sequence with appearancemotion correspondence. In: Proceedings of the IEEE/CVF international conference\non computer vision. pp. 1273–1283 (2019)\n26. Pang, G., Yan, C., Shen, C., Hengel, A.v.d., Bai, X.: Self-trained deep ordinal regression for end-to-end video anomaly detection. In: Proceedings of the IEEE/CVF\nconference on computer vision and pattern recognition. pp. 12173–12182 (2020)\n\n\fInterleaving OCC and WS Models with Adaptive Thresholding for UVAD\n\n17\n\n27. Park, H., Noh, J., Ham, B.: Learning memory-guided normality for anomaly detection. In: Proceedings of the IEEE/CVF conference on computer vision and pattern\nrecognition. pp. 14372–14381 (2020)\n28. Sapkota, H., Yu, Q.: Bayesian nonparametric submodular video partition for robust\nanomaly detection. In: Proceedings of the IEEE/CVF Conference on Computer\nVision and Pattern Recognition. pp. 3212–3221 (2022)\n29. Shi, C., Sun, C., Wu, Y., Jia, Y.: Video anomaly detection via sequentially learning\nmultiple pretext tasks. In: Proceedings of the IEEE/CVF International Conference\non Computer Vision. pp. 10330–10340 (2023)\n30. Smeureanu, S., Ionescu, R.T., Popescu, M., Alexe, B.: Deep appearance features for\nabnormal behavior detection in video. In: Image Analysis and Processing-ICIAP\n2017: 19th International Conference, Catania, Italy, September 11-15, 2017, Proceedings, Part II 19. pp. 779–789. Springer (2017)\n31. Sohrab, F., Raitoharju, J., Gabbouj, M., Iosifidis, A.: Subspace support vector\ndata description. In: 2018 24th International Conference on Pattern Recognition\n(ICPR). pp. 722–727. IEEE (2018)\n32. Sultani, W., Chen, C., Shah, M.: Real-world anomaly detection in surveillance\nvideos. In: Proceedings of the IEEE conference on computer vision and pattern\nrecognition. pp. 6479–6488 (2018)\n33. Sun, S., Gong, X.: Hierarchical semantic contrast for scene-aware video anomaly\ndetection. In: Proceedings of the IEEE/CVF Conference on Computer Vision and\nPattern Recognition (CVPR). pp. 22846–22856 (June 2023)\n34. Tian, Y., Pang, G., Chen, Y., Singh, R., Verjans, J.W., Carneiro, G.: Weaklysupervised video anomaly detection with robust temporal feature magnitude learning. In: Proceedings of the IEEE/CVF international conference on computer vision.\npp. 4975–4986 (2021)\n35. Tran, D., Bourdev, L., Fergus, R., Torresani, L., Paluri, M.: Learning spatiotemporal features with 3d convolutional networks. In: Proceedings of the IEEE international conference on computer vision. pp. 4489–4497 (2015)\n36. Tudor Ionescu, R., Smeureanu, S., Alexe, B., Popescu, M.: Unmasking the abnormal events in video. In: Proceedings of the IEEE international conference on\ncomputer vision. pp. 2895–2903 (2017)\n37. Tur, A.O., Dall’Asen, N., Beyan, C., Ricci, E.: Exploring diffusion models for unsupervised video anomaly detection. In: 2023 IEEE International Conference on\nImage Processing (ICIP). pp. 2540–2544. IEEE (2023)\n38. Wan, B., Fang, Y., Xia, X., Mei, J.: Weakly supervised video anomaly detection\nvia center-guided discriminative learning. In: 2020 IEEE international conference\non multimedia and expo (ICME). pp. 1–6. IEEE (2020)\n39. Wang, G., Wang, Y., Qin, J., Zhang, D., Bao, X., Huang, D.: Video anomaly detection by solving decoupled spatio-temporal jigsaw puzzles. In: European Conference\non Computer Vision. pp. 494–511. Springer (2022)\n40. Wang, J., Song, Y., Leung, T., Rosenberg, C., Wang, J., Philbin, J., Chen, B., Wu,\nY.: Learning fine-grained image similarity with deep ranking. In: Proceedings of\nthe IEEE conference on computer vision and pattern recognition. pp. 1386–1393\n(2014)\n41. Wang, J., Cherian, A.: Gods: Generalized one-class discriminative subspaces for\nanomaly detection. In: Proceedings of the IEEE/CVF International Conference on\nComputer Vision. pp. 8201–8211 (2019)\n42. Wang, Z., Zou, Y., Zhang, Z.: Cluster attention contrast for video anomaly detection. In: Proceedings of the 28th ACM international conference on multimedia. pp.\n2463–2471 (2020)\n\n\f18\n\nY. Nie et al.\n\n43. Wu, J.C., Hsieh, H.Y., Chen, D.J., Fuh, C.S., Liu, T.L.: Self-supervised sparse\nrepresentation for video anomaly detection. In: European Conference on Computer\nVision. pp. 729–745. Springer (2022)\n44. Wu, P., Liu, J., Shi, Y., Sun, Y., Shao, F., Wu, Z., Yang, Z.: Not only look, but\nalso listen: Learning multimodal violence detection under weak supervision. In:\nComputer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August\n23–28, 2020, Proceedings, Part XXX 16. pp. 322–339. Springer (2020)\n45. Yan, C., Zhang, S., Liu, Y., Pang, G., Wang, W.: Feature prediction diffusion\nmodel for video anomaly detection. In: Proceedings of the IEEE/CVF International\nConference on Computer Vision (ICCV). pp. 5527–5537 (October 2023)\n46. Yang, Z., Liu, J., Wu, Z., Wu, P., Liu, X.: Video event restoration based on\nkeyframes for video anomaly detection. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 14592–14601\n(June 2023)\n47. Zaheer, M.Z., Mahmood, A., Khan, M.H., Segu, M., Yu, F., Lee, S.I.: Generative\ncooperative learning for unsupervised video anomaly detection. In: Proceedings of\nthe IEEE/CVF conference on computer vision and pattern recognition. pp. 14744–\n14754 (2022)\n48. Zaheer, M.Z., Mahmood, A., Astrid, M., Lee, S.I.: Claws: Clustering assisted\nweakly supervised learning with normalcy suppression for anomalous event detection. In: Computer Vision–ECCV 2020: 16th European Conference, Glasgow,\nUK, August 23–28, 2020, Proceedings, Part XXII 16. pp. 358–376. Springer (2020)\n49. Zhang, C., Li, G., Qi, Y., Wang, S., Qing, L., Huang, Q., Yang, M.H.: Exploiting\ncompleteness and uncertainty of pseudo labels for weakly supervised video anomaly\ndetection. In: Proceedings of the IEEE/CVF Conference on Computer Vision and\nPattern Recognition (CVPR). pp. 16271–16280 (June 2023)\n50. Zhang, J., Qing, L., Miao, J.: Temporal convolutional network with complementary\ninner bag loss for weakly supervised anomaly detection. In: 2019 IEEE International Conference on Image Processing (ICIP). pp. 4030–4034. IEEE (2019)\n51. Zhang, T., Lu, H., Li, S.Z.: Learning semantic scene models by object classification\nand trajectory clustering. In: 2009 IEEE conference on computer vision and pattern\nrecognition. pp. 1940–1947. IEEE (2009)\n52. Zhao, Y., Deng, B., Shen, C., Liu, Y., Lu, H., Hua, X.S.: Spatio-temporal autoencoder for video anomaly detection. In: Proceedings of the 25th ACM international\nconference on Multimedia. pp. 1933–1941 (2017)\n53. Zhong, J.X., Li, N., Kong, W., Liu, S., Li, T.H., Li, G.: Graph convolutional label\nnoise cleaner: Train a plug-and-play action classifier for anomaly detection. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition.\npp. 1237–1246 (2019)\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"