File size: 8,955 Bytes
c4caa9a e659e9f c4caa9a e659e9f c4caa9a 89d1a73 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>YOLO Vision — macOS WebGPU</title>
<link rel="stylesheet" href="style.css" />
<!-- Load ONNX Runtime WebGPU Bundle directly -->
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.webgpu.min.js"></script>
</head>
<body>
<div class="ambient-glow"></div>
<!-- macOS Window Container -->
<main class="window-container">
<!-- Window Titlebar -->
<header class="window-titlebar">
<div class="traffic-lights">
<span class="traffic-dot close"></span>
<span class="traffic-dot minimize"></span>
<span class="traffic-dot maximize"></span>
</div>
<div class="titlebar-center">
<span>YOLO Vision</span>
<span>•</span>
<strong>YOLO11 & YOLO26 WebGPU</strong>
</div>
<div>
<div id="engine-badge" class="badge-engine">
<span id="badge-dot" class="badge-dot loading"></span>
<span id="badge-text">WebGPU Init...</span>
</div>
</div>
</header>
<!-- Window Body -->
<div class="window-content">
<!-- Left Sidebar Controls -->
<aside class="sidebar">
<!-- Model Selection -->
<div class="control-card">
<div class="card-heading">Neural Engine</div>
<div class="select-wrapper">
<label class="select-label" for="model-preset">Model Architecture</label>
<select id="model-preset" class="macos-select">
<optgroup label="YOLO26 (Next-Gen NMS-Free)">
<option value="yolo26n" selected>YOLO26 Nano (9.5 MB) • Real-Time</option>
<option value="yolo26s">YOLO26 Small (36.5 MB) • Accurate</option>
<option value="yolo26m">YOLO26 Medium (78 MB) • High Precision</option>
</optgroup>
<optgroup label="YOLO11 (Ultra-Fast Anchor-Free)">
<option value="yolo11n">YOLO11 Nano (10.3 MB) • Lightweight</option>
<option value="yolo11s">YOLO11 Small (36.3 MB) • Balanced</option>
<option value="yolo11m">YOLO11 Medium (77 MB) • Enterprise</option>
</optgroup>
</select>
</div>
<div class="select-wrapper">
<label class="select-label" for="device-preset">Hardware Acceleration</label>
<select id="device-preset" class="macos-select">
<option value="webgpu" selected>WebGPU (Apple Silicon / Discrete GPU)</option>
<option value="wasm">WASM SIMD (CPU Fallback)</option>
</select>
</div>
<!-- Sleek Apple-style Loader -->
<div id="loader-box" class="loader-box">
<div class="loader-header">
<span id="loader-status">Preloading weights...</span>
<span id="loader-percent">0%</span>
</div>
<div class="progress-track">
<div id="loader-bar" class="progress-fill"></div>
</div>
</div>
</div>
<!-- Detection Parameters -->
<div class="control-card">
<div class="card-heading">Inference Tuning</div>
<div class="slider-container">
<div class="slider-top">
<span>Confidence Threshold</span>
<span id="conf-val" class="val">0.35</span>
</div>
<input type="range" id="conf-slider" class="macos-slider" min="0.10" max="0.95" step="0.05" value="0.35" />
</div>
<label class="checkbox-row" for="person-filter">
<input type="checkbox" id="person-filter" />
<span>Person only filter</span>
</label>
</div>
<!-- Metric HUD -->
<div class="control-card">
<div class="card-heading">Telemetry</div>
<div class="metrics-grid">
<div class="metric-tile">
<div class="metric-name">Latency</div>
<div class="metric-num"><span id="metric-latency">--</span><span style="font-size:12px;color:var(--text-secondary)"> ms</span></div>
</div>
<div class="metric-tile">
<div class="metric-name">Frame Rate</div>
<div class="metric-num"><span id="metric-fps">--</span><span style="font-size:12px;color:var(--text-secondary)"> fps</span></div>
</div>
<div class="metric-tile" style="grid-column: span 2;">
<div class="metric-name">Objects Detected</div>
<div class="metric-num"><span id="metric-count">0</span></div>
</div>
</div>
</div>
</aside>
<!-- Main Canvas Viewport -->
<section class="main-viewport">
<!-- macOS Segmented Control Tabs -->
<div class="segmented-control">
<button id="tab-webcam" class="segment-btn active" onclick="switchTabUI('webcam')">Live Camera</button>
<button id="tab-media" class="segment-btn" onclick="switchTabUI('media')">Image & Video</button>
</div>
<!-- Canvas Container -->
<div class="canvas-wrapper">
<!-- Hidden source elements for frame capture -->
<video id="live-video" autoplay playsinline muted style="display: none;"></video>
<video id="file-video" playsinline muted loop style="display: none;"></video>
<img id="file-image" style="display: none;" />
<canvas id="display-canvas"></canvas>
<!-- Idle State: Camera -->
<div id="cam-idle-overlay" class="viewport-empty-state">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M23 7l-7 5 7 5V7z"></path>
<rect x="1" y="5" width="15" height="14" rx="3" ry="3"></rect>
</svg>
<p>FaceTime HD Camera feed is inactive</p>
<button id="start-cam-btn" class="apple-btn primary">Enable Camera</button>
</div>
<!-- Idle State: File Upload Drop Zone -->
<div id="media-idle-overlay" class="viewport-empty-state" style="display: none;">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="3" y="3" width="18" height="18" rx="3" ry="3"></rect>
<circle cx="8.5" cy="8.5" r="1.5"></circle>
<polyline points="21 15 16 10 5 21"></polyline>
</svg>
<p>Drag & drop image or video here</p>
<label for="media-file-input" class="apple-btn primary" style="cursor: pointer;">
Choose File
</label>
<input type="file" id="media-file-input" accept="image/*,video/*" style="display: none;" />
</div>
</div>
<!-- Bottom Toolbar -->
<div class="bottom-toolbar">
<div id="webcam-controls" style="display: flex; gap: 8px;">
<button id="stop-cam-btn" class="apple-btn" disabled>Pause Camera</button>
</div>
<div id="media-controls" style="display: none; gap: 8px;">
<button id="video-play-btn" class="apple-btn">Play Video</button>
<label for="media-file-input-2" class="apple-btn" style="cursor: pointer;">Change Media</label>
<input type="file" id="media-file-input-2" accept="image/*,video/*" style="display: none;" />
</div>
<div style="font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono);">
Zero server dependencies • 100% Client-Side
</div>
</div>
</section>
</div>
</main>
<div id="toast" class="toast-notice">Notice</div>
<script>
// Immediate UI switcher for tabs ensuring zero delay or module blocking
window.switchTabUI = function(tab) {
const tabWebcam = document.getElementById('tab-webcam');
const tabMedia = document.getElementById('tab-media');
const camIdle = document.getElementById('cam-idle-overlay');
const mediaIdle = document.getElementById('media-idle-overlay');
const webcamControls = document.getElementById('webcam-controls');
const mediaControls = document.getElementById('media-controls');
if (tab === 'webcam') {
tabWebcam.classList.add('active');
tabMedia.classList.remove('active');
camIdle.style.display = 'flex';
mediaIdle.style.display = 'none';
webcamControls.style.display = 'flex';
mediaControls.style.display = 'none';
} else {
tabMedia.classList.add('active');
tabWebcam.classList.remove('active');
camIdle.style.display = 'none';
mediaIdle.style.display = 'flex';
webcamControls.style.display = 'none';
}
};
</script>
<script src="app.js"></script>
</body>
</html>
|