Image Annotation and Dataset Preparation Platform
VisionTag is a lightweight, browser-based image annotation studio built with Python, Streamlit, and a custom HTML5 Canvas component (st.components.v2.component). It enables computer vision engineers and dataset annotators to upload multiple images, draw pixel-accurate object bounding boxes, author structured scene descriptions, validate annotation quality, and export training-ready datasets in VisionTag JSON, YOLO, and COCO formats.
Preparing clean, validated object-detection and scene-understanding datasets often requires heavyweight desktop tools or cloud services with external accounts, GPU dependencies, or brittle third-party canvas plugins. VisionTag provides a self-contained, local-first web application with strict coordinate validation, per-image session isolation, and standard CV dataset exports.
- Multi-Image Workspace: Upload multiple images (
PNG,JPG,JPEG,WEBP), deduplicate identical files by content hash, disambiguate duplicate filenames, and switch seamlessly between images in the sidebar. - Interactive HTML5 Bounding-Box Canvas: Click-and-drag rectangular bounding boxes directly over aspect-ratio-preserved images using Streamlit Components v2 (
st.components.v2.component) with live dashed previews, color-coded labels, and optional confidence scores. - Original Pixel Coordinate Mapping: Automatically converts displayed canvas coordinates to original image pixel coordinates (
top_leftxywh), regardless of display scaling. - Per-Image State Isolation: Bounding boxes and scene-level annotation fields (
description,subjects,objects,actions,environment,lighting,mood,spatial_relationships) are isolated per image and persist across Streamlit reruns and image switches. - Quality Validation Engine: Distinguishes blocking errors (
REJECTED— empty labels, negative coordinates, non-positive dimensions, out-of-bounds boxes, duplicate IDs, non-finite numbers) from warnings (REVIEW_REQUIRED— boxes< 5 px, low confidence< 0.5, duplicate geometries, missing scene context). - Multi-Format Dataset Export:
- VisionTag JSON (
visiontag_annotation.json): Scene annotation + image metadata + original dimensions + coordinate convention + bounding boxes. - YOLO (
.txtper image or.zipbundle withclasses.txtandlabels/*.txt): Normalizedclass_id x_center y_center width height. - COCO (
visiontag_coco.json): Completeinfo,images,annotations, andcategoriescollections.
- VisionTag JSON (
flowchart LR
UI["Streamlit UI (app.py)"] --> WS["Workspace Manager (src/media/workspace.py)"]
UI --> Canvas["HTML5 Canvas Component (src/ui/bbox_canvas.py)"]
Canvas -->|Canvas coords| BBox["BBox & Coord Utils (src/annotation/bbox.py)"]
BBox -->|Original px coords| Val["Validator (src/annotation/validator.py)"]
WS --> Val
Val -->|PASSED / REVIEW_REQUIRED| Exp["Exporters (src/export/)"]
Exp --> JSON["Native JSON"]
Exp --> YOLO["YOLO .txt / .zip"]
Exp --> COCO["COCO JSON"]
VisionTag/
├── app.py # Streamlit application entrypoint
├── requirements.txt # Verified Python dependencies
├── LICENSE # MIT License
├── assets/screenshots/ # Verified UI screenshots
├── examples/ # Sample JSON, YOLO, and COCO exports
├── src/
│ ├── annotation/
│ │ ├── bbox.py # Bounding-box model & coordinate conversion
│ │ ├── schema.py # Scene annotation schema
│ │ └── validator.py # Scene & bounding-box validation rules
│ ├── export/
│ │ ├── json_exporter.py # Extended VisionTag JSON export
│ │ ├── yolo_exporter.py # YOLO .txt and .zip dataset export
│ │ └── coco_exporter.py # COCO JSON dataset export
│ ├── media/
│ │ ├── image_loader.py # Pillow image inspection utility
│ │ └── workspace.py # Multi-image state & isolation manager
│ └── ui/
│ └── bbox_canvas.py # Custom HTML5 Canvas (Components v2)
└── tests/
├── test_bbox.py # Coordinate & bounding-box validation tests
├── test_export.py # JSON, YOLO, and COCO export tests
├── test_image_loader.py # Image inspection tests
├── test_validator.py # Scene validation tests
└── test_workspace.py # Multi-image & state isolation tests
- Language: Python 3.14.3
- Web Framework: Streamlit 1.68.0 (
st.components.v2.component) - Frontend Canvas: Custom HTML5
<canvas>+ Pointer Events (zero external JS dependencies) - Image Processing: Pillow 12.3.0
- Testing: Pytest 9.2.0 & Playwright (browser-level E2E QA)
git clone <your-repo-url>
cd VisionTag
python -m venv .venv
# Windows PowerShell:
.venv\Scripts\Activate.ps1
# macOS/Linux:
# source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.pyOpen the local URL printed by Streamlit (typically http://localhost:8501).
- Upload Images: Use the Media Workspace sidebar to upload one or more images.
- Select Active Image: Switch between uploaded images via the Workspace images dropdown.
- Draw Bounding Boxes: Enter an object label (and optionally enable a confidence score), then click and drag on the canvas.
- Add Scene Context: Fill in scene description, subjects, objects, actions, environment, lighting, mood, and spatial relationships.
- Validate & Export: Click Validate & Create Annotation to view the quality report and download VisionTag JSON, YOLO (
.txtor.zip), or COCO JSON.
Sample exports are included in examples/:
- Native VisionTag JSON:
examples/sample_visiontag.json - COCO JSON:
examples/sample_coco.json - YOLO:
examples/sample_yolo.txt&examples/classes.txt
Run the full automated test suite:
python -m pytest -vAll 36 automated unit & integration tests pass, covering image inspection, coordinate conversion, bounding-box & scene validation, multi-image workspace isolation, and JSON/YOLO/COCO exports.
VisionTag is self-contained with standard pure-Python/wheel dependencies (requirements.txt) and requires no GPU or paid APIs, making it compatible with Streamlit Community Cloud, Render, or Hugging Face Spaces (Streamlit SDK). Because no external hosting credentials are configured in this local environment, no public URL is claimed here; follow the local setup steps above for reproducible execution.
- In-memory session persistence: Annotations are stored in
st.session_statefor the active browser session; refreshing the browser tab resets the workspace. - Immutable boxes after draw: To adjust a bounding box's position or label, delete the box and redraw it.
- Future Scope: In-place box resize/move handles, server-side project persistence (SQLite/JSON), and keyboard shortcuts for rapid labeling.


