lgonda1998's picture
Fix blur slider and comparison log values
dc82b62 verified
Raw History Blame Contribute Delete
7.15 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Browser-based image classification and object detection using pretrained Hugging Face models">
<title>AI Image Classification &amp; Object Detection</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>">
<link rel="stylesheet" href="./style.css?v=4">
</head>
<body>
<main class="page-shell">
<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>
<header class="hero">
<p class="eyebrow">Creative Technology · Computer Vision</p>
<h1>AI Image Classification &amp; Object Detection</h1>
<p class="lede">Use the same image and model, then vary blur from 0px to 50px to observe how prediction confidence changes.</p>
<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>
</header>
<section class="workspace" aria-label="Computer vision mini-lab">
<div class="controls card">
<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>
<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>
<div id="sample-grid" class="sample-grid" aria-label="Example images"></div>
<div class="or-row"><span>or try your own</span></div>
<label class="control-label" for="image-input">Upload an image</label><p class="helper">PNG, JPEG, or WebP works best.</p>
<input id="image-input" class="file-input" type="file" accept="image/png,image/jpeg,image/webp">
<div class="divider"></div>
<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>
<div class="divider"></div>
<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>
<div class="divider"></div>
<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>
<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>
</div>
<div class="result card">
<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>
<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>
<div id="summary" class="summary">No results yet.</div>
<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>
<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>
</div>
</section>
<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><p class="explain-copy"><strong>Why blur?</strong> Image classifiers and object detectors rely on edges, textures, shapes, and fine visual details. Blur progressively removes high-frequency detail while preserving the overall scene, making it a controlled way to test model robustness. Comparing 0px with stronger blur shows whether confidence decreases gradually, whether the top label changes, and which models remain reliable when image quality is reduced.</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>
<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>Blur</th><th>Top result</th><th>Score</th><th>Time</th></tr></thead><tbody id="history-body"><tr class="empty-row"><td colspan="7">Run the same image at 0px and 50px blur to start a comparison.</td></tr></tbody></table></div></section>
<footer>Hosted as a Hugging Face Static Space · Powered by Transformers.js</footer>
</main>
<script type="module" src="./app.js?v=11"></script>
</body>
</html>