Skip to main content

MoonLabel

MoonLabel Logo

An object-detection and image-caption dataset tool.

Powered by Multimodal LLMs (OpenAI, Gemini, Claude, Ollama, OpenRouter, vLLM) & Moondream VLM

PyPI version PyPI Downloads


Overview

MoonLabel is both a Python library and a lightweight web UI to generate object-detection and image-caption datasets quickly.

  1. Use the library to auto-label folders of images and export YOLO, COCO, VOC, or Captions.
  2. Or launch the UI, switch between Detection/Caption, and export with one click.

Supported backends:

  • Multimodal LLMs (zero extra dependencies): OpenAI (GPT-4o / GPT-4.1), Google Gemini (native box_2d 0–1000 grounding), Anthropic Claude, Ollama (local VLMs like qwen2.5vl, llama3.2-vision, gemma3), OpenRouter, and any OpenAI-compatible endpoint (vLLM, LM Studio, Groq, Together, etc.).
  • Moondream VLM: Moondream Cloud, Moondream Station, or fully local (Hugging Face).
  • Custom backends: Implement VisionBackend to plug in any custom vision model.

Demo

https://github.com/user-attachments/assets/a2dfc6b6-c83d-4296-986b-ac221e10fc3b


Features

  • 🤖 Multimodal LLM support — OpenAI, Google Gemini, Anthropic Claude, Ollama, OpenRouter, and any OpenAI-compatible vision API.
  • 📦 Library + UI — moonlabel package with an optional web UI.
  • 🌐 FastAPI server — Served by a single moonlabel-ui command.
  • ⚛️ Modern frontend — React, TypeScript, TailwindCSS, Vite.
  • 🖼️ Object detection — Single-pass multi-class detection with Multimodal LLMs, plus Moondream Cloud / Station / Local HF.
  • 📝 Image caption datasets — Export captions as captions.jsonl alongside images, with length presets or custom prompts.
  • ⚡ GPU-accelerated & offline — Local Ollama, vLLM, Moondream Station, and Hugging Face modes run fully offline.

Install

  • Library only (Multimodal LLMs + Moondream Cloud/Station):
pip install moonlabel
  • Library + UI server:
pip install "moonlabel[ui]"
  • Local Moondream (Hugging Face) extras:
pip install "moonlabel[local]"
  • Both UI and local Hugging Face inference:
pip install "moonlabel[ui,local]"

Quick Start (UI)

pip install "moonlabel[ui]"
moonlabel-ui    # opens http://localhost:8342

Choose a provider in Settings:

  • Multimodal LLMs: OpenAI, Google Gemini, Anthropic Claude, Ollama (Local), OpenRouter, or OpenAI-Compatible (vLLM / LM Studio / custom base_url)
  • Moondream: Cloud (API key), Station (http://localhost:2020/v1), or Local (Hugging Face)

In the Home page:

  • Use the top toggle to select Detection or Caption dataset.
  • For Caption, choose length (short/normal/long) or enter an optional custom prompt, then generate and export.

Quick Start (Library)

Using Multimodal LLMs

API keys can be passed via api_key=... or read automatically from environment variables (OPENAI_API_KEY, GEMINI_API_KEY / GOOGLE_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY).

from moonlabel import create_dataset

# Google Gemini (uses native 0-1000 box_2d grounding)
create_dataset(
    "/path/to/images",
    objects=["person", "car"],
    provider="gemini",
    model="gemini-2.5-flash",
    api_key="YOUR_GEMINI_API_KEY",  # or GEMINI_API_KEY env var
)

# OpenAI (GPT-4o / GPT-4o-mini / GPT-4.1)
create_dataset(
    "/path/to/images",
    objects=["person", "dog"],
    provider="openai",
    model="gpt-4o-mini",
    api_key="YOUR_OPENAI_API_KEY",  # or OPENAI_API_KEY env var
)

# Anthropic Claude
create_dataset(
    "/path/to/images",
    objects=["bicycle", "helmet"],
    provider="anthropic",
    model="claude-sonnet-4-20250514",
    api_key="YOUR_ANTHROPIC_API_KEY",  # or ANTHROPIC_API_KEY env var
)

# Ollama (local multimodal LLMs: qwen2.5vl, llama3.2-vision, gemma3, llava, ...)
create_dataset(
    "/path/to/images",
    objects=["laptop", "cup"],
    provider="ollama",
    model="qwen2.5vl",
    base_url="http://localhost:11434/v1",  # default
)

# OpenRouter
create_dataset(
    "/path/to/images",
    objects=["car", "traffic light"],
    provider="openrouter",
    model="qwen/qwen2.5-vl-72b-instruct",
    api_key="YOUR_OPENROUTER_API_KEY",  # or OPENROUTER_API_KEY env var
)

# Any OpenAI-compatible server (vLLM, LM Studio, Groq, Together, etc.)
create_dataset(
    "/path/to/images",
    objects=["person"],
    provider="openai-compatible",
    model="Qwen/Qwen2.5-VL-7B-Instruct",
    base_url="http://localhost:8000/v1",
)

Using Moondream (Cloud / Station / Local)

from moonlabel import create_dataset

# Cloud
create_dataset("/path/to/images", objects=["person"], api_key="YOUR_API_KEY")

# Station
create_dataset("/path/to/images", objects=["car"], station_endpoint="http://localhost:2020/v1")

# Local (after: pip install "moonlabel[local]")
create_dataset("/path/to/images", objects=["bottle"])  # no key needed

Export Formats

By default create_dataset exports YOLO. Choose formats via export_format:

# YOLO (default)
create_dataset("/path/to/images", objects=["person"], export_format="yolo", provider="gemini")

# COCO
create_dataset("/path/to/images", objects=["person", "car"], export_format="coco", provider="openai")

# Pascal VOC
create_dataset("/path/to/images", objects=["cat", "dog"], export_format="voc", provider="anthropic")

# Image Captioning (short | normal | long)
create_dataset("/path/to/images", export_format="caption", caption_length="normal", provider="openai")

# Image Captioning with a custom prompt
create_dataset(
    "/path/to/images",
    export_format="caption",
    caption_prompt="Describe the product and any visible surface defects in one sentence.",
    provider="gemini",
)

Output layouts:

  • YOLO: images/, labels/, classes.txt
  • COCO: images/, annotations/instances.json, classes.txt
  • VOC: images/, annotations/*.xml, classes.txt
  • Caption: images/, annotations/captions.jsonl

Direct Inference & Custom Backends

You can also run inference directly on single images or implement a custom VisionBackend:

from moonlabel import MultimodalInference, VisionBackend, create_dataset

client = MultimodalInference(provider="gemini", model="gemini-2.5-flash")
image, detections = client.detect("photo.jpg", ["person", "car"])
image, caption = client.caption("photo.jpg", length="normal")

# Or pass a pre-configured / custom VisionBackend directly
create_dataset("/path/to/images", objects=["person"], backend=client)

Moondream Station Mode

The backend can connect to a running Moondream Station instance for fast, native, on-device inference.

  1. Download, install, and run Moondream Station.
  2. Ensure the endpoint matches your Station configuration (default: http://localhost:2020/v1).

Local Mode (Hugging Face)

The backend can run fully offline using the open-source vikhyatk/moondream2 checkpoint.

  1. pip install "moonlabel[local]"
  2. In the UI, select Moondream Local (HF) (no API key required).

The first detection will trigger a one-off model download to ~/.cache/huggingface/; subsequent runs reuse the cached weights.

GPU / Device selection

The backend chooses the best device automatically in the following order: CUDA → Apple Silicon (MPS) → CPU.

Override via environment variable before launching the backend:

# Force GPU
export MOONDREAM_DEVICE=cuda

# Force Apple Silicon
export MOONDREAM_DEVICE=mps

# CPU only
export MOONDREAM_DEVICE=cpu

Project Structure

moonlabel/
├── src/moonlabel/             # Python package (library + server)
│   ├── backends.py            # Multimodal LLM backends (OpenAI, Gemini, Anthropic, Ollama, OpenRouter, Custom)
│   ├── dataset.py             # create_dataset API
│   ├── infer.py               # Moondream wrapper (cloud/station/local) + re-exports
│   ├── types.py               # shared types
│   ├── utils.py               # helpers
│   ├── yolo.py                # YOLO label writer
│   ├── coco.py                # COCO writer
│   ├── voc.py                 # Pascal VOC XML writer
│   └── server/                # FastAPI app + static assets
│       ├── api.py
│       ├── cli.py             # moonlabel-ui entrypoint (port 8342)
│       └── static/            # embedded UI build (no npm for users)
├── ui/                        # Frontend source (for maintainers)
│   └── dist/                  # Built files to embed
├── scripts/embed_ui.py        # Copies ui/dist → src/moonlabel/server/static
├── Makefile                   # make ui-build, ui-embed, release
└── pyproject.toml

Roadmap / TODOs

Below are planned enhancements and upcoming features. Contributions welcome!

  • Multimodal LLM support – OpenAI, Google Gemini, Anthropic Claude, Ollama, OpenRouter, and OpenAI-compatible APIs.
  • Local Hugging Face model support – Offline inference with optional GPU acceleration.
  • Moondream Station integration – Native Mac/Linux app support for on-device inference.
  • Batch uploads – Label multiple images in one go, with progress tracking.
  • Additional export formats – COCO JSON and Pascal VOC alongside YOLO.

License

This project is licensed under the terms of the Apache License 2.0. See LICENSE for details.

Metadata

Release files for moonlabel 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moonlabel 0.2.0
File Size Uploaded Provenance Actions
moonlabel-0.2.0.tar.gz 161.2 kB Without provenance Details for moonlabel-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moonlabel 0.2.0
File Interpreter ABI Platform Actions
moonlabel-0.2.0-py3-none-any.whl Python 3 none any Details for moonlabel-0.2.0-py3-none-any.whl

Total release size: 317.8 kB

Release files / moonlabel-0.2.0.tar.gz

Download URL moonlabel-0.2.0.tar.gz
Size 161.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d9f0b119061079916afc6e27d383285bdd4cafa3831d5190b958f5fefdf2db0e
BLAKE2b-256 checksum
How to use checksums
77163c20edaffdabc4889903ddf28b94af2b5e011f112db37850d4be62307efa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / moonlabel-0.2.0-py3-none-any.whl

Download URL moonlabel-0.2.0-py3-none-any.whl
Size 156.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af375c31e9f51e6cdc6e18d13f42aa5b65a87950a1811c8929a2fc9a1663ce8a
BLAKE2b-256 checksum
How to use checksums
15d39ec7407cb25f24d444f29aed40db89bb8c4d39f5f20f622818a97e31b9e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Security for moonlabel 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page