Skip to content
simpsonr06Public

About

Image Annotation and Dataset Preparation Platform with interactive HTML5 Canvas bounding boxes, validation, and JSON/YOLO/COCO exports.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

VisionTag

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.


Problem Statement

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.


Key Features

  • 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_left xywh), 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 (.txt per image or .zip bundle with classes.txt and labels/*.txt): Normalized class_id x_center y_center width height.
    • COCO (visiontag_coco.json): Complete info, images, annotations, and categories collections.

Architecture Overview

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"]
Loading

Project Structure

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

Technology Stack

  • 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)

Installation & Usage

Local Setup

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.py

Open the local URL printed by Streamlit (typically http://localhost:8501).

Annotation Workflow

  1. Upload Images: Use the Media Workspace sidebar to upload one or more images.
  2. Select Active Image: Switch between uploaded images via the Workspace images dropdown.
  3. Draw Bounding Boxes: Enter an object label (and optionally enable a confidence score), then click and drag on the canvas.
  4. Add Scene Context: Fill in scene description, subjects, objects, actions, environment, lighting, mood, and spatial relationships.
  5. Validate & Export: Click Validate & Create Annotation to view the quality report and download VisionTag JSON, YOLO (.txt or .zip), or COCO JSON.

Supported Annotation Formats

Sample exports are included in examples/:


Screenshots

Empty Workspace

Empty Workspace

Interactive Bounding-Box Canvas & Scene Annotation

Interactive Canvas

Quality Validation & Dataset Export (JSON, YOLO, COCO)

Validation and Exports


Testing

Run the full automated test suite:

python -m pytest -v

All 36 automated unit & integration tests pass, covering image inspection, coordinate conversion, bounding-box & scene validation, multi-image workspace isolation, and JSON/YOLO/COCO exports.


Deployment Notes

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.


Known Limitations & Future Scope

  • In-memory session persistence: Annotations are stored in st.session_state for 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.

About

Image Annotation and Dataset Preparation Platform with interactive HTML5 Canvas bounding boxes, validation, and JSON/YOLO/COCO exports.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages