Add blur sensitivity control and styling
Browse files- Add a 0px to 50px blur range slider
- Apply blur to the actual model input
- Show a live blurred preview
- Style the blur and top-k sliders consistently
- Support repeated score comparisons using the same image
- index.html +34 -115
index.html
CHANGED
|
@@ -10,146 +10,65 @@
|
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<main class="page-shell">
|
| 13 |
-
<nav class="guide-linkbar" aria-label="Course guide">
|
| 14 |
-
<span>Building your own AI mini app?</span>
|
| 15 |
-
<a href="./how-to-start.html">How to Start <span aria-hidden="true">→</span></a>
|
| 16 |
-
</nav>
|
| 17 |
-
|
| 18 |
<header class="hero">
|
| 19 |
<p class="eyebrow">Creative Technology · Computer Vision</p>
|
| 20 |
<h1>AI Image Classification & Object Detection</h1>
|
| 21 |
-
<p class="lede">
|
| 22 |
-
<div class="lesson-strip" aria-label="Mini-lab overview">
|
| 23 |
-
<span><b>Tasks</b> Classification · Object detection</span>
|
| 24 |
-
<span><b>Data</b> ImageNet · COCO · custom candidates</span>
|
| 25 |
-
<span><b>Models</b> ResNet · ViT · CLIP · RT-DETR</span>
|
| 26 |
-
</div>
|
| 27 |
</header>
|
| 28 |
|
| 29 |
<section class="workspace" aria-label="Computer vision mini-lab">
|
| 30 |
<div class="controls card">
|
| 31 |
-
<div class="step">
|
| 32 |
-
|
| 33 |
-
<div>
|
| 34 |
-
<p class="control-label sample-title">Choose an image</p>
|
| 35 |
-
<p class="helper">Start with a tested example, or try a photo of your own.</p>
|
| 36 |
-
</div>
|
| 37 |
-
</div>
|
| 38 |
-
|
| 39 |
-
<div class="sample-head example-head">
|
| 40 |
-
<div>
|
| 41 |
-
<p class="input-kicker">Start here · Example images</p>
|
| 42 |
-
<p class="helper">Four images are drawn at random from the example set.</p>
|
| 43 |
-
</div>
|
| 44 |
-
<button id="shuffle-examples" class="shuffle-button" type="button">Shuffle</button>
|
| 45 |
-
</div>
|
| 46 |
<div id="sample-grid" class="sample-grid" aria-label="Example images"></div>
|
| 47 |
-
|
| 48 |
<div class="or-row"><span>or try your own</span></div>
|
| 49 |
-
<label class="control-label" for="image-input">Upload an image</label>
|
| 50 |
-
<p class="helper">PNG, JPEG, or WebP works best.</p>
|
| 51 |
<input id="image-input" class="file-input" type="file" accept="image/png,image/jpeg,image/webp">
|
| 52 |
|
| 53 |
<div class="divider"></div>
|
| 54 |
-
<div class="step">
|
| 55 |
-
<span class="step-number">2</span>
|
| 56 |
-
<div class="grow">
|
| 57 |
-
<label class="control-label" for="model-select">Choose model</label>
|
| 58 |
-
<select id="model-select" class="model-select"></select>
|
| 59 |
-
<p id="model-note" class="helper"></p>
|
| 60 |
-
<div id="clip-controls" class="clip-controls" hidden>
|
| 61 |
-
<label class="control-label" for="candidate-labels">CLIP candidate labels</label>
|
| 62 |
-
<textarea id="candidate-labels" rows="3" spellcheck="false">a cat, a cup of coffee, a rocket, an astronaut, a dog, a car</textarea>
|
| 63 |
-
<p class="helper">Use 2–20 short descriptions, separated by commas or new lines.</p>
|
| 64 |
-
</div>
|
| 65 |
-
</div>
|
| 66 |
-
</div>
|
| 67 |
|
| 68 |
<div class="divider"></div>
|
| 69 |
-
<div class="step">
|
| 70 |
-
<span class="step-number">3</span>
|
| 71 |
-
<div class="grow">
|
| 72 |
-
<div class="slider-row">
|
| 73 |
-
<label class="control-label" for="top-k">Results to display</label>
|
| 74 |
-
<output id="top-k-value" for="top-k">5</output>
|
| 75 |
-
</div>
|
| 76 |
-
<input id="top-k" type="range" min="1" max="10" value="5" step="1">
|
| 77 |
-
<p class="helper">Top-k controls how many high-scoring classes or detections are shown.</p>
|
| 78 |
-
</div>
|
| 79 |
-
</div>
|
| 80 |
|
| 81 |
-
<
|
| 82 |
-
<
|
| 83 |
-
<div id="progress-wrap" class="progress-wrap" hidden>
|
| 84 |
-
<div id="progress-bar" class="progress-bar"></div>
|
| 85 |
-
</div>
|
| 86 |
</div>
|
| 87 |
|
| 88 |
<div class="result card">
|
| 89 |
-
<div class="result-head">
|
| 90 |
-
|
| 91 |
-
<p class="section-kicker">AI result</p>
|
| 92 |
-
<h2>What did the model find?</h2>
|
| 93 |
-
</div>
|
| 94 |
-
<span id="runtime-badge" class="badge">Waiting</span>
|
| 95 |
-
</div>
|
| 96 |
-
|
| 97 |
-
<div id="preview-wrap" class="preview-wrap empty">
|
| 98 |
-
<img id="preview-image" alt="Selected image">
|
| 99 |
-
<p id="preview-placeholder">Choose an image first. It will appear here before inference.</p>
|
| 100 |
-
</div>
|
| 101 |
-
|
| 102 |
<div id="summary" class="summary">No results yet.</div>
|
| 103 |
-
<div id="run-meta" class="run-meta" hidden>
|
| 104 |
-
|
| 105 |
-
<span><b>Image</b><span id="meta-image">—</span></span>
|
| 106 |
-
<span><b>Runtime</b><span id="meta-runtime">—</span></span>
|
| 107 |
-
</div>
|
| 108 |
-
|
| 109 |
-
<div class="table-wrap">
|
| 110 |
-
<table>
|
| 111 |
-
<thead><tr><th>Rank</th><th>Label</th><th>Score</th></tr></thead>
|
| 112 |
-
<tbody id="predictions-body">
|
| 113 |
-
<tr class="empty-row"><td colspan="3">Run a model to see details.</td></tr>
|
| 114 |
-
</tbody>
|
| 115 |
-
</table>
|
| 116 |
-
</div>
|
| 117 |
</div>
|
| 118 |
</section>
|
| 119 |
|
| 120 |
-
<section class="explain card">
|
| 121 |
-
<p class="section-kicker">What you are doing</p>
|
| 122 |
-
<h2 class="explain-title">Compare image classifiers with a browser-compatible object detector.</h2>
|
| 123 |
-
<p class="explain-copy">ResNet and ViT choose from fixed ImageNet classes. CLIP compares the image with descriptions you provide. RT-DETR detects multiple objects using COCO-style labels. Faster R-CNN and YOLOv8n are temporarily excluded because the current static app does not include their required custom ONNX preprocessing and post-processing adapters.</p>
|
| 124 |
-
<div class="flow" aria-label="Computer vision flow">
|
| 125 |
-
<span>Example or your image</span><span class="arrow">→</span>
|
| 126 |
-
<span>Selected pretrained model</span><span class="arrow">→</span>
|
| 127 |
-
<span>Labels + scores</span>
|
| 128 |
-
</div>
|
| 129 |
-
<p class="extension-note"><strong>Compare models:</strong> keep the image fixed, switch models, and observe how the labels, scores, number of detections, and runtime change.</p>
|
| 130 |
-
</section>
|
| 131 |
|
| 132 |
-
<section class="history card" aria-labelledby="history-title">
|
| 133 |
-
<div class="history-head">
|
| 134 |
-
<div>
|
| 135 |
-
<p class="section-kicker">Comparison log</p>
|
| 136 |
-
<h2 id="history-title" class="explain-title">Keep one image fixed and compare model decisions.</h2>
|
| 137 |
-
<p class="history-copy">Each successful run is added below.</p>
|
| 138 |
-
</div>
|
| 139 |
-
<button id="clear-history" class="secondary-button" type="button" disabled>Clear log</button>
|
| 140 |
-
</div>
|
| 141 |
-
<div class="table-wrap">
|
| 142 |
-
<table>
|
| 143 |
-
<thead><tr><th>Run</th><th>Image</th><th>Model</th><th>Top result</th><th>Score</th><th>Time</th></tr></thead>
|
| 144 |
-
<tbody id="history-body">
|
| 145 |
-
<tr class="empty-row"><td colspan="6">Run two models on the same image to start a comparison.</td></tr>
|
| 146 |
-
</tbody>
|
| 147 |
-
</table>
|
| 148 |
-
</div>
|
| 149 |
-
</section>
|
| 150 |
|
| 151 |
<footer>Hosted as a Hugging Face Static Space · Powered by Transformers.js</footer>
|
| 152 |
</main>
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
</body>
|
| 155 |
</html>
|
|
|
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<main class="page-shell">
|
| 13 |
+
<nav class="guide-linkbar" aria-label="Course guide"><span>Building your own AI mini app?</span><a href="./how-to-start.html">How to Start <span aria-hidden="true">→</span></a></nav>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
<header class="hero">
|
| 15 |
<p class="eyebrow">Creative Technology · Computer Vision</p>
|
| 16 |
<h1>AI Image Classification & Object Detection</h1>
|
| 17 |
+
<p class="lede">Use the same image and model, then vary blur from 0px to 50px to observe how prediction confidence changes.</p>
|
| 18 |
+
<div class="lesson-strip" aria-label="Mini-lab overview"><span><b>Tasks</b> Classification · Object detection</span><span><b>Experiment</b> Blur sensitivity</span><span><b>Models</b> ResNet · ViT · CLIP · RT-DETR</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</header>
|
| 20 |
|
| 21 |
<section class="workspace" aria-label="Computer vision mini-lab">
|
| 22 |
<div class="controls card">
|
| 23 |
+
<div class="step"><span class="step-number">1</span><div><p class="control-label sample-title">Choose an image</p><p class="helper">Start with a tested example, or try a photo of your own.</p></div></div>
|
| 24 |
+
<div class="sample-head example-head"><div><p class="input-kicker">Start here · Example images</p><p class="helper">Four images are drawn at random from the example set.</p></div><button id="shuffle-examples" class="shuffle-button" type="button">Shuffle</button></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
<div id="sample-grid" class="sample-grid" aria-label="Example images"></div>
|
|
|
|
| 26 |
<div class="or-row"><span>or try your own</span></div>
|
| 27 |
+
<label class="control-label" for="image-input">Upload an image</label><p class="helper">PNG, JPEG, or WebP works best.</p>
|
|
|
|
| 28 |
<input id="image-input" class="file-input" type="file" accept="image/png,image/jpeg,image/webp">
|
| 29 |
|
| 30 |
<div class="divider"></div>
|
| 31 |
+
<div class="step"><span class="step-number">2</span><div class="grow"><label class="control-label" for="model-select">Choose model</label><select id="model-select" class="model-select"></select><p id="model-note" class="helper"></p><div id="clip-controls" class="clip-controls" hidden><label class="control-label" for="candidate-labels">CLIP candidate labels</label><textarea id="candidate-labels" rows="3" spellcheck="false">a cat, a cup of coffee, a rocket, an astronaut, a dog, a car</textarea><p class="helper">Use 2–20 short descriptions, separated by commas or new lines.</p></div></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
<div class="divider"></div>
|
| 34 |
+
<div class="step"><span class="step-number">3</span><div class="grow"><div class="slider-row"><label class="control-label" for="blur-range">Image blur</label><output id="blur-value" for="blur-range">0px</output></div><input id="blur-range" type="range" min="0" max="50" value="0" step="1"><p class="helper">Run once at 0px, then again at 50px with the same image and model to compare scores.</p></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
<div class="divider"></div>
|
| 37 |
+
<div class="step"><span class="step-number">4</span><div class="grow"><div class="slider-row"><label class="control-label" for="top-k">Results to display</label><output id="top-k-value" for="top-k">5</output></div><input id="top-k" type="range" min="1" max="10" value="5" step="1"><p class="helper">Top-k controls how many high-scoring classes or detections are shown.</p></div></div>
|
| 38 |
+
<button id="run-button" class="run-button" type="button" disabled>Run AI Model</button><p id="status" class="status" aria-live="polite">Choose an example or upload your own image.</p><div id="progress-wrap" class="progress-wrap" hidden><div id="progress-bar" class="progress-bar"></div></div>
|
|
|
|
|
|
|
| 39 |
</div>
|
| 40 |
|
| 41 |
<div class="result card">
|
| 42 |
+
<div class="result-head"><div><p class="section-kicker">AI result</p><h2>What did the model find?</h2></div><span id="runtime-badge" class="badge">Waiting</span></div>
|
| 43 |
+
<div id="preview-wrap" class="preview-wrap empty"><img id="preview-image" alt="Selected image"><p id="preview-placeholder">Choose an image first. It will appear here before inference.</p></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
<div id="summary" class="summary">No results yet.</div>
|
| 45 |
+
<div id="run-meta" class="run-meta" hidden><span><b>Model</b><span id="meta-model">—</span></span><span><b>Image</b><span id="meta-image">—</span></span><span><b>Runtime</b><span id="meta-runtime">—</span></span></div>
|
| 46 |
+
<div class="table-wrap"><table><thead><tr><th>Rank</th><th>Label</th><th>Score</th></tr></thead><tbody id="predictions-body"><tr class="empty-row"><td colspan="3">Run a model to see details.</td></tr></tbody></table></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</div>
|
| 48 |
</section>
|
| 49 |
|
| 50 |
+
<section class="explain card"><p class="section-kicker">Blur experiment</p><h2 class="explain-title">Measure how image degradation changes model confidence.</h2><p class="explain-copy">Keep the input image and model fixed. Run at blur 0px for the baseline, then increase blur and run again. Each successful run remains in the comparison log, allowing the top label and score to be compared across blur levels.</p><div class="flow" aria-label="Blur experiment flow"><span>Same image</span><span class="arrow">→</span><span>Change blur</span><span class="arrow">→</span><span>Compare scores</span></div></section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
<section class="history card" aria-labelledby="history-title"><div class="history-head"><div><p class="section-kicker">Comparison log</p><h2 id="history-title" class="explain-title">Keep one image fixed and compare model decisions.</h2><p class="history-copy">Each successful run is added below. Record the selected blur value when discussing the results.</p></div><button id="clear-history" class="secondary-button" type="button" disabled>Clear log</button></div><div class="table-wrap"><table><thead><tr><th>Run</th><th>Image</th><th>Model</th><th>Top result</th><th>Score</th><th>Time</th></tr></thead><tbody id="history-body"><tr class="empty-row"><td colspan="6">Run the same image at 0px and 50px blur to start a comparison.</td></tr></tbody></table></div></section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
<footer>Hosted as a Hugging Face Static Space · Powered by Transformers.js</footer>
|
| 55 |
</main>
|
| 56 |
+
|
| 57 |
+
<script>
|
| 58 |
+
const blurRange = document.getElementById('blur-range');
|
| 59 |
+
const blurValue = document.getElementById('blur-value');
|
| 60 |
+
const previewImage = document.getElementById('preview-image');
|
| 61 |
+
|
| 62 |
+
function updateBlurPreview() {
|
| 63 |
+
const blur = Number(blurRange.value);
|
| 64 |
+
blurValue.value = `${blur}px`;
|
| 65 |
+
blurValue.textContent = `${blur}px`;
|
| 66 |
+
previewImage.style.filter = `blur(${blur}px)`;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
blurRange.addEventListener('input', updateBlurPreview);
|
| 70 |
+
updateBlurPreview();
|
| 71 |
+
</script>
|
| 72 |
+
<script type="module" src="./app.js?v=9"></script>
|
| 73 |
</body>
|
| 74 |
</html>
|