Spaces:
Running
Running
Download index.html from cltsangwork/Topic5APIC: direct link, hf CLI and curl.
- Browser
- Download file 12.8 kB
-
https://huggingface.co/spaces/cltsangwork/Topic5APIC/resolve/main/index.html
- Command line
-
hf download hf://spaces/cltsangwork/Topic5APIC/index.html
-
curl -L -o index.html https://huggingface.co/spaces/cltsangwork/Topic5APIC/resolve/main/index.html
12.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <meta name="description" content="An image captioning mini-lab comparing three pretrained Hugging Face models side by side."> | |
| <title>AI-Powered Image Captioning</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"> | |
| <link rel="stylesheet" href="./captioning.css"> | |
| </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-Powered Image Captioning</h1> | |
| <p class="lede">Choose an example or upload your own image, then run all three pretrained captioners and compare how each one answers: <strong>what is happening in this image?</strong></p> | |
| <div class="lesson-strip" aria-label="Mini-lab overview"> | |
| <span><b>Task</b> Image captioning</span> | |
| <span><b>Output</b> Three descriptions in English</span> | |
| <span><b>Models</b> ViT-GPT2 · Florence-2 · SmolVLM</span> | |
| </div> | |
| </header> | |
| <section class="workspace" aria-label="Image captioning 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 an 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 from a bank of teaching examples.</p> | |
| </div><button id="shuffle-examples" class="shuffle-button" type="button" disabled>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 · up to 12 MB.</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"> | |
| <p class="control-label">Run all three captioners</p> | |
| <p class="helper">They share the same image, so their descriptions can be compared directly. Each captioner keeps its own options below its result.</p> | |
| </div></div> | |
| <button id="run-button" class="run-button" type="button" disabled>Run all three captioners</button> | |
| <button id="stop-button" class="secondary-button stop-button" type="button" hidden>Stop this run</button> | |
| <p id="status" class="status" role="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 descriptions</p><h2>How does each model describe it?</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 captioning.</p></div> | |
| <p id="image-source" class="helper" hidden></p> | |
| <div id="captioner-grid" class="captioner-grid"> | |
| <article class="captioner-panel" data-model="vit" aria-labelledby="title-vit"> | |
| <div class="panel-head"> | |
| <div><p class="panel-kicker">Captioner 1</p><h3 id="title-vit" class="panel-title" data-role="title"></h3></div> | |
| <span class="badge panel-badge" data-role="badge">Waiting</span> | |
| </div> | |
| <p class="panel-note helper" data-role="note"></p> | |
| <div class="panel-caption" data-role="caption">No caption yet.</div> | |
| <p class="panel-meta" data-role="meta" hidden></p> | |
| <div class="panel-actions"> | |
| <button class="secondary-button" type="button" data-role="copy" disabled>Copy caption</button> | |
| <button class="secondary-button" type="button" data-role="save" disabled>Save caption</button> | |
| </div> | |
| <div class="panel-options"> | |
| <p class="panel-options-title">Options for this captioner</p> | |
| <label class="control-label" for="style-vit">Description style</label> | |
| <select id="style-vit" class="model-select" data-role="style" disabled> | |
| <option value="short">Short caption (fixed)</option> | |
| </select> | |
| <p class="helper" data-role="detail"></p> | |
| <div class="token-controls"> | |
| <div class="slider-row"><label class="control-label" for="tokens-vit">Maximum new tokens</label><output class="token-value" data-role="token-value" for="tokens-vit">64</output></div> | |
| <input id="tokens-vit" class="token-slider" data-role="tokens" type="range" min="32" max="128" value="64" step="16"> | |
| <p class="helper">An output limit, not an exact word count.</p> | |
| </div> | |
| <p class="panel-stale helper" data-role="stale" hidden>Settings changed — run again to update this caption.</p> | |
| </div> | |
| </article> | |
| <article class="captioner-panel" data-model="florence" aria-labelledby="title-florence"> | |
| <div class="panel-head"> | |
| <div><p class="panel-kicker">Captioner 2</p><h3 id="title-florence" class="panel-title" data-role="title"></h3></div> | |
| <span class="badge panel-badge" data-role="badge">Waiting</span> | |
| </div> | |
| <p class="panel-note helper" data-role="note"></p> | |
| <div class="panel-caption" data-role="caption">No caption yet.</div> | |
| <p class="panel-meta" data-role="meta" hidden></p> | |
| <div class="panel-actions"> | |
| <button class="secondary-button" type="button" data-role="copy" disabled>Copy caption</button> | |
| <button class="secondary-button" type="button" data-role="save" disabled>Save caption</button> | |
| </div> | |
| <div class="panel-options"> | |
| <p class="panel-options-title">Options for this captioner</p> | |
| <label class="control-label" for="style-florence">Description style</label> | |
| <select id="style-florence" class="model-select" data-role="style"> | |
| <option value="short">Short caption</option> | |
| <option value="detailed">Detailed description</option> | |
| </select> | |
| <p class="helper" data-role="detail"></p> | |
| <div class="token-controls"> | |
| <div class="slider-row"><label class="control-label" for="tokens-florence">Maximum new tokens</label><output class="token-value" data-role="token-value" for="tokens-florence">64</output></div> | |
| <input id="tokens-florence" class="token-slider" data-role="tokens" type="range" min="32" max="128" value="64" step="16"> | |
| <p class="helper">An output limit, not an exact word count.</p> | |
| </div> | |
| <p class="panel-stale helper" data-role="stale" hidden>Settings changed — run again to update this caption.</p> | |
| </div> | |
| </article> | |
| <article class="captioner-panel" data-model="smol" aria-labelledby="title-smol"> | |
| <div class="panel-head"> | |
| <div><p class="panel-kicker">Captioner 3</p><h3 id="title-smol" class="panel-title" data-role="title"></h3></div> | |
| <span class="badge panel-badge" data-role="badge">Waiting</span> | |
| </div> | |
| <p class="panel-note helper" data-role="note"></p> | |
| <div class="panel-caption" data-role="caption">No caption yet.</div> | |
| <p class="panel-meta" data-role="meta" hidden></p> | |
| <div class="panel-actions"> | |
| <button class="secondary-button" type="button" data-role="copy" disabled>Copy caption</button> | |
| <button class="secondary-button" type="button" data-role="save" disabled>Save caption</button> | |
| </div> | |
| <div class="panel-options"> | |
| <p class="panel-options-title">Options for this captioner</p> | |
| <label class="control-label" for="style-smol">Description style</label> | |
| <select id="style-smol" class="model-select" data-role="style"> | |
| <option value="short">Short caption</option> | |
| <option value="detailed">Detailed description</option> | |
| </select> | |
| <p class="helper" data-role="detail"></p> | |
| <div class="clip-controls"> | |
| <label class="control-label" for="instruction-smol">Description instruction</label> | |
| <textarea id="instruction-smol" rows="3" maxlength="400" spellcheck="false">Describe this image in one short sentence.</textarea> | |
| <p class="helper">Keep the image fixed and change the instruction to compare.</p> | |
| </div> | |
| <div class="token-controls"> | |
| <div class="slider-row"><label class="control-label" for="tokens-smol">Maximum new tokens</label><output class="token-value" data-role="token-value" for="tokens-smol">64</output></div> | |
| <input id="tokens-smol" class="token-slider" data-role="tokens" type="range" min="32" max="128" value="64" step="16"> | |
| <p class="helper">An output limit, not an exact word count.</p> | |
| </div> | |
| <p class="panel-stale helper" data-role="stale" hidden>Settings changed — run again to update this caption.</p> | |
| </div> | |
| </article> | |
| </div> | |
| <div class="table-wrap"><table><thead><tr><th>Check the descriptions</th><th>Look for visual evidence</th></tr></thead><tbody> | |
| <tr><td>Objects and attributes</td><td>Are the named objects and their details visible?</td></tr> | |
| <tr><td>Actions and relationships</td><td>Does each sentence explain what is actually happening?</td></tr> | |
| <tr><td>Missing or added details</td><td>Which model omits something? Which adds details without evidence?</td></tr> | |
| </tbody></table></div> | |
| </div> | |
| </section> | |
| <section class="explain card"> | |
| <p class="section-kicker">What you are doing</p> | |
| <h2 class="explain-title">Use a learned AI capability instead of rebuilding the traditional task from scratch.</h2> | |
| <p class="explain-copy">A visual encoder represents the image. A language decoder generates a description. Different models may describe different details, and a fluent sentence can still be wrong.</p> | |
| <div class="flow" aria-label="Image captioning flow"><span>One example or your image</span><span class="arrow">→</span><span>Three pretrained captioners, side by side</span><span class="arrow">→</span><span>Three descriptions in words</span></div> | |
| <p class="extension-note"><strong>Compare models:</strong> all three see the same image. Check which objects, actions, and relationships each sentence captures—or invents—and adjust one captioner's options to test a controlled change.</p> | |
| </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 descriptions.</h2><p class="history-copy">The latest 12 successful captions stay here until you clear the log or reload. Generation time excludes model loading; download the log to keep the full settings.</p></div><div class="history-actions"><button id="download-history" class="secondary-button" disabled>Download log</button><button id="clear-history" class="secondary-button" disabled>Clear log</button></div></div> | |
| <div class="table-wrap"><table><thead><tr><th>Run</th><th>Image</th><th>Model</th><th>Caption</th><th>Style</th><th>Time</th></tr></thead><tbody id="history-body"><tr class="empty-row"><td colspan="6">Run the captioners on an image 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"></script> | |
| </body> | |
| </html> | |