Creative Technology · Build your own AI mini app

How to Start

Run a pretrained captioner, understand its output, and build one useful improvement.

1. Explore the demo

  1. Choose one of the example images or upload a PNG, JPEG, or WebP image.
  2. Start with ViT-GPT2 and select Run AI Captioning.
  3. Allow time for the first model download. Subsequent runs can reuse cached files. Use Stop this run if needed.
  4. Read the caption and check its objects, actions, and relationships against the image.
  5. Keep the same image and try Florence-2 or SmolVLM. Compare the actual sentences in the log.

2. Change one thing

Florence-2 supports short and detailed captioning tasks. SmolVLM accepts a description instruction. ViT-GPT2 produces a short caption without an instruction. The output-token limit is not a target word count.

Choose one experiment: compare models, change the requested detail, or crop an image. Record both successes and failures. Download the comparison log before reloading the page.

3. Make your own Hugging Face Space

  1. Sign in to Hugging Face and open this project's Space page.
  2. Use the Space menu to duplicate it into your own account. Alternatively, create a new Static Space and upload this folder's files with their subfolders.
  3. Keep sdk: static and app_file: index.html in the README metadata.
  4. Wait for the Space to build, open its App tab, and test one example and one uploaded image.

This project needs no API key, paid inference endpoint, or training job. Internet access is required to obtain the library and model files.

4. Find the code that matters

FileWhat to change
index.htmlThe task explanation and page structure.
app.jsImage selection, result display, and comparison records.
models.jsModel IDs, pinned revisions, and task settings.
captioner.jsLoad the model, prepare inputs, generate tokens, decode the caption.
caption-worker.jsRun inference separately so the page stays responsive.
examples/Teaching images, manifest, and source records.

When changing a model, check its Transformers.js support and input format. A Python model ID cannot always be substituted directly.

5. Explain and submit

If something does not work

Model download fails: check access to Hugging Face and jsDelivr, then retry. The first run loads roughly a few hundred MB per model.

Generation is slow: use a recent desktop browser, close memory-heavy tabs, choose a shorter output limit, or stop the run. Loading time is shown separately from generation time.

The sentence is wrong: save the actual output and identify the unsupported detail. Try another model or a clearer image; a fluent sentence is not a guarantee of correctness.

Local files do not load: serve the folder over HTTP instead of opening index.html with file://.

python -m http.server 7860

Open http://localhost:7860. Uploaded images are processed in your browser. They are not sent to an inference server.

Example image sources · Transformers.js documentation