InstaCaption
Upload any image, or choose to use a live webcam version, into a caption!
Built on BLIP, an
open image-captioning model from Salesforce, run locally via Hugging Face
transformers. No API key required, and after the first run (which downloads
the model, ~1GB) it works fully offline.
Setup
- Python 3.9+ is recommended
- Install dependencies:
bash pip install -r requirements.txt- If you have an NVIDIA GPU and want faster inference, you can install a CUDA-enabled build of PyTorch first by following https://pytorch.org/get-started/locally/, then install the rest of the requirements.
- The first time you run either script, it will download the BLIP model (a few hundred MB to ~1GB depending on variant). This only happens once.
Usage
GUI app
python instacaption.py
Opens a window with two buttons:
- Caption your Image — opens your file browser, click on any image to generate a caption
- Live Webcam — opens a webcam window with a live-updating caption
overlaid on the video. Press
qin that window to stop.
Note: while live mode is running, the main InstaCaption window will look
unresponsive, it goes back to normal as soon as you press q.
Or run a single mode from the command line
If you only ever want one mode and prefer a CLI:
python caption_image.py path/to/photo.jpg # caption a single image
python caption_image.py # ...or opens a file picker
python caption_live.py # live webcam captioning
python caption_live.py --camera 1 # use a different webcam
python caption_live.py --interval 1.0 # caption more frequently (default: every 2s)
Captioning runs a bit slower than real-time video, so the live mode updates
the caption periodically (every --interval seconds) rather than on every
single frame — this keeps the video feed smooth while still refreshing the
caption regularly.
Project structure
InstaCaption/
├── instacaption.py # GUI entry point: buttons for image mode and live mode
├── captioner.py # Core model-loading + captioning logic (shared by both modes)
├── caption_image.py # Image-captioning logic; also runnable standalone from the CLI
├── caption_live.py # Live webcam captioning logic; also runnable standalone from the CLI
├── requirements.txt
└── README.md
Notes & tips
- Better quality captions: swap
MODEL_NAMEincaptioner.pyfromSalesforce/blip-image-captioning-basetoSalesforce/blip-image-captioning-largefor noticeably better captions at the cost of a larger download and slower inference. - Speed: on CPU, expect roughly 0.5–2 seconds per caption depending on your machine. A GPU will be much faster.
- Custom prompts:
Captioner.caption()accepts an optionalpromptargument (e.g."a photo of") to help steer the caption's phrasing.
Log in or sign up for Devpost to join the conversation.