Skip to main content

A simple tagger to tag your medias by user-defined open-source AI model, especially working for Hydrus Network.

Project description

Omni Tagger

Also Available in Chinese(中文)

A versatile media tagging CLI tool that tags images, animations, and videos using custom deep‑learning models (e.g., DeepDanbooru) and integrates seamlessly with Hydrus media server.

Features

  • Multi‑format support: Tags both images and videos by extracting frames.
  • Model‑agnostic: Works with any ONNX‑format model; pre‑configured for DeepDanbooru.
  • Hydrus integration: Pulls media by hash from a Hydrus instance and pushes predicted tags back.
  • Clipboard‑ready: Reads SHA‑256 hashes directly from the clipboard for quick operations.
  • Batch processing: Tags multiple files in one run with a progress bar.
  • Automatic namespace assignment: Can optionally prepend category‑based namespaces (e.g., character:, rating:) to tags.
  • Rating detection: Models that output rating scores (safe, questionable, explicit, etc.) are supported.
  • Extensible registry: Add your own models by dropping a folder into models/ with a metainfo.yaml file.

Installation

Prerequisites

  • Python ≥ 3.11
  • CUDA 12.1 (optional, for GPU acceleration)
  • A running Hydrus instance (if you want to use the Hydrus integration)

Using uv (recommended)

This project uses uv for dependency management and packaging.

  1. Clone the repository:

    git clone https://github.com/your‑username/omni‑tagger.git
    cd omni‑tagger
    
  2. Install the package in editable mode:

    uv pip install -e .
    

    This will install all dependencies listed in pyproject.toml, including the GPU‑ready versions of PyTorch and ONNX Runtime when CUDA is available.

Using pip

If you prefer plain pip, you can install from the local directory:

pip install -e .

Usage

After installation, the CLI command hydrus is available.

1. Set up Hydrus configuration

Create a .env file in the project root (or in your user config directory) with the following variables:

HYDRUS_API_KEY=your_access_key_here
HYDRUS_ENDPOINT=http://localhost:45869
HYDRUS_TAG_SERVICE=my tags

Alternatively, you can set these environment variables directly.

2. Register a model

Omni Tagger looks for models inside a models/ directory (created automatically on first run). Each model must be a sub‑directory containing:

  • metainfo.yaml – model metadata (see example below)
  • the ONNX checkpoint file
  • a CSV or TXT file listing the tags (one per line)

Example metainfo.yaml:

name: "deepdanbooru"
checkpoint_path: "model.onnx"
tag_path: "tags.csv"
is_rating: false
num_rating: 0
height: 512
width: 512

Place the model folder under models/ (e.g., models/deepdanbooru/). The registry is built automatically when the tool starts.

3. Tag media from Hydrus

The main command is hydrus eval. It reads SHA‑256 hashes from the clipboard (or from command‑line arguments) and tags the corresponding media.

# Copy some hashes to your clipboard, then run:
hydrus eval --threshold 0.35 --enable-auto-namespace

Options:

  • --threshold – confidence threshold for accepting a tag (default: 0.35)
  • --enable-auto-namespace – automatically prepend namespace based on tag categories
  • --rating-only – only output rating tags, skip regular tags

You can also pass the hashes directly as arguments:

hydrus eval abc123def... xyz789...

4. List registered models

hydrus print_model

Shows the details of every model currently registered.

5. Stand‑alone tagging (without Hydrus)

You can also use the tagging engine programmatically. Import TaggerModel from omni_tagger.modules.tagger and follow the examples in the source code.

Configuration Files

  • Hydrus config: Located at ~/.config/omni‑tagger/hydrus.yaml (or via environment variables). See src/omni_tagger/config/hydrus.py for the schema.
  • Logs: Written to logs/image‑renamer.log (rotated weekly).

Model Registry Details

The registry is built by scanning models/ for sub‑directories that contain a metainfo.yaml. The YAML file must define at least:

  • checkpoint_path – relative path to the ONNX file inside the model directory
  • tag_path – relative path to the tag list (CSV or TXT)
  • is_rating – boolean indicating whether the model outputs rating scores
  • num_rating – number of rating classes (if is_rating is true)
  • height / width – input dimensions expected by the model

Development

Project structure

src/omni_tagger/
├── __main__.py          # CLI entry point (Typer app)
├── modules/
│   ├── tagger/          # Core tagging logic (TaggerModel, ONNX wrapper)
│   └── hydrus/          # Hydrus API client
├── config/              # Configuration loaders
└── utils/               # Helper functions

Running tests

Currently no formal test suite is set up. Contributions are welcome.

Code style

The project uses black for formatting and ruff for linting. Please run them before submitting a pull request.

black .
ruff check --fix .

Contributing

  1. Fork the repository.
  2. Create a feature branch.
  3. Implement your changes with appropriate tests.
  4. Ensure the code passes formatting and linting checks.
  5. Submit a pull request with a clear description of the change.

License

MIT – see the LICENSE file (if present) for details.

Acknowledgments

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

omni_anime_tagger-1.0.0.tar.gz (101.8 kB view details)

Uploaded Source

Built Distribution

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

omni_anime_tagger-1.0.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file omni_anime_tagger-1.0.0.tar.gz.

File metadata

  • Download URL: omni_anime_tagger-1.0.0.tar.gz
  • Upload date:
  • Size: 101.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for omni_anime_tagger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 39f5ac13f55d310c76a67d34dd26c2311ac3396667e36716b48b925ea6e414b5
MD5 62a62420ca957af0b110e3edd4f0f54d
BLAKE2b-256 168bb2094e40db2e372c577499bb450f388e021ddc39b87dce63a33cfcdabcc2

See more details on using hashes here.

File details

Details for the file omni_anime_tagger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: omni_anime_tagger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for omni_anime_tagger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ffd464d0612d1c89876eecc7b447ab2d52669c2a388b61b3e01f595ededb4fdf
MD5 c16791a68d8daf061166394b4662fe09
BLAKE2b-256 3ba17313d3ce96fc62e71cc305040c77ef31d94699494163963bd3ccfaebd312

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