Skip to main content

AI-powered image annotation tool for Google Colab

Project description

DriverFlow โ€” Intelligent Image Annotation Tool

A polished, cloud-ready annotation tool powered by GroundingDINO for zero-shot object detection. Deploy to Google Colab in minutes.

Features

โœจ Zero-shot Detection โ€” Detect any objects using natural language prompts
๐ŸŽฏ Interactive UI โ€” Upload images, adjust model parameters, preview results in real-time
๐Ÿ“Š Structured Output โ€” Generate YOLO format annotations automatically
โ˜๏ธ Colab Native โ€” Runs entirely in Google Colab with ngrok or Colab proxy tunneling
๐ŸŽจ Polished Design โ€” Dark theme UI with real-time feedback and smooth interactions

Prerequisites

  1. Google Colab access
  2. GitHub Personal Access Token (PAT) with repo scope
  3. (Optional) ngrok auth token for persistent public URL

Quick Start

  1. Open colab_launcher.ipynb in Google Colab
  2. Fill in your GitHub credentials in the first cell:
    GITHUB_TOKEN = "your_github_pat_here"
    GITHUB_USERNAME = "your_github_username"
    NGROK_TOKEN = "your_ngrok_token_here"  # optional
    
  3. Click Runtime โ†’ Run all
  4. Wait for the setup to complete (2โ€“3 minutes)
  5. Click the printed URL to open the DriverFlow UI

Usage

  1. Upload Image โ€” Drag and drop or click to browse
  2. Enter Text Prompt โ€” Describe objects to detect (e.g., car . person . traffic light)
  3. Adjust Thresholds (optional)
    • Box Threshold (0.1โ€“0.9, default 0.35) โ€” higher = more confident detections only
    • Text Threshold (0.1โ€“0.9, default 0.25) โ€” higher = stricter text-alignment matching
  4. Click Detect โ€” Model runs and returns:
    • Annotated image with bounding boxes and class labels
    • Summary table with detection counts and average confidence scores
  5. Download โ€” Export results as YOLO format (ZIP file with annotations.txt + classes.txt)

YOLO Format

The tool exports bounding box annotations in YOLO format:

annotations.txt (one detection per line):

<class_id> <cx> <cy> <w> <h>
  • class_id โ€” integer index (0-based, sorted alphabetically by class name)
  • cx, cy, w, h โ€” normalized coordinates (0โ€“1 range)
    • cx, cy โ€” box center (relative to image width/height)
    • w, h โ€” box width and height (relative to image width/height)

classes.txt (one class name per line, alphabetically sorted):

car
person
traffic light

Architecture

DriverFlow/
โ”œโ”€โ”€ colab_launcher.ipynb       # Colab entry point
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py                 # FastAPI server + GroundingDINO integration
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ””โ”€โ”€ static/
โ”‚       โ”œโ”€โ”€ index.html         # UI markup
โ”‚       โ”œโ”€โ”€ style.css          # Dark theme styling
โ”‚       โ””โ”€โ”€ app.js             # Browser logic & API calls
โ””โ”€โ”€ README.md

Backend Stack

  • FastAPI โ€” web framework
  • GroundingDINO โ€” zero-shot object detection model
  • OpenCV โ€” image processing
  • uvicorn โ€” ASGI server
  • pyngrok โ€” ngrok integration for Colab tunneling

Frontend Stack

  • Vanilla HTML5/CSS3/JS โ€” no build step, no dependencies
  • Drag-and-drop file upload with live image preview
  • Real-time slider feedback for model parameters
  • Base64 image embedding for inline results
  • ZIP download via Blob API

API Reference

POST /api/detect

Runs GroundingDINO inference on an uploaded image.

Request (multipart/form-data):

Field Type Default Description
image File โ€” Image file (JPEG, PNG, etc.)
text_prompt str โ€” Detection prompt (e.g., "car . person")
box_threshold float 0.35 Objectness score cutoff
text_threshold float 0.25 Text-alignment score cutoff

Response (200 application/json):

{
  "detections": [
    {
      "phrase": "car",
      "confidence": 0.87,
      "box_cxcywh": [0.51, 0.48, 0.12, 0.18]
    }
  ],
  "class_counts": [
    {"class": "car", "count": 3, "avg_confidence": 0.75},
    {"class": "person", "count": 1, "avg_confidence": 0.92}
  ],
  "annotated_image_b64": "<base64 JPEG string>",
  "image_width": 1280,
  "image_height": 720
}

POST /api/download_yolo

Generates a ZIP file with YOLO format annotations.

Request (application/json):

{
  "detections": [ ... ],
  "image_width": 1280,
  "image_height": 720
}

Response (200 application/zip):

  • classes.txt โ€” alphabetically sorted class names
  • annotations.txt โ€” normalized CXCYWH format

Security Notes

โš ๏ธ Do NOT commit colab_launcher.ipynb with credentials filled in to a public repository.

  • The notebook stores your GitHub PAT as a plain Python string
  • If you push the notebook with credentials, immediately revoke the token at https://github.com/settings/tokens
  • Best practice: Use GitHub's PAT scoping to limit what the token can do

Troubleshooting

"Module not found" errors during Colab setup

  • Some GPU/CPU compatibility issues can arise. Re-run the installer cell. CUDA patches are applied idempotently.

ngrok connection fails

  • Free tier allows one simultaneous tunnel. If you have an old tunnel active, run ngrok.kill() first.
  • Ngrok token scope: ensure it's from a free account with no connections limit.

Colab proxy times out

  • Colab's built-in proxy may close after 30 minutes of inactivity. Use an ngrok token for persistent access.

Slow detection on CPU

  • GroundingDINO's SwinT variant is the fastest available checkpoint. Colab's GPU is usually allocated automatically; ensure you're not on a CPU-only runtime.

Missing annotations or low confidence

  • Adjust thresholds downward (e.g., 0.25 โ†’ 0.15) to be more permissive
  • Refine text prompts: instead of "object," try specific descriptions like "red car" or "traffic sign"

Model Details

Model: GroundingDINO SwinT-OGC (Swin Transformer Tiny, Object Grounding with Captions)

  • Checkpoint: groundingdino_swint_ogc.pth
  • Size: ~400 MB
  • Architecture: Vision Transformer + BERT-based text encoder + cross-modal reasoning
  • License: Apache 2.0 (IDEA-Research/GroundingDINO)

License

This project is provided as-is. GroundingDINO is licensed under Apache 2.0. See https://github.com/IDEA-Research/GroundingDINO for details.

Contributing

To modify or extend DriverFlow:

  1. Clone this repo locally
  2. Edit files in backend/
  3. Commit and push changes
  4. Re-run colab_launcher.ipynb to test in Colab (it pulls the latest main branch)

Support

For issues or feedback:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

driverflow-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

driverflow-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file driverflow-0.1.0.tar.gz.

File metadata

  • Download URL: driverflow-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for driverflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 55aa11dd29ba1d66f18e0f62607ebddaf6cd22452ed39cac85f4c3e9802e565f
MD5 2743a53b37364049c6c46949791dbcad
BLAKE2b-256 54eb1f6510b521e70c9610e82af1148529664791639139cef720bf876061613a

See more details on using hashes here.

File details

Details for the file driverflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: driverflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for driverflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed8ff9619ff41ec8d104116e0db4bf68ef48f6f39d3336f628133145e4192e8f
MD5 de46ae461e47384d41b244d3f4b1249e
BLAKE2b-256 2967c52c973eab4bcfa028bb4fb66e4a306a5db6038f2ad87a79092eb3c93e9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page