DEV Community

Zhirong Yang
Zhirong Yang

Posted on

Build a Tag-Based Search System for Anime-Style Images in C++

Introduction

When you manage a large folder of anime-style illustrations on your PC, you often want to filter images by specific tags (e.g., miko, blonde hair, short hair).
So I built a lightweight web app in C++ that searches a local image folder by tags.

👉 Live demo: http://198.13.48.172:8080/

This post covers:

  • What the app does and its key features
  • How to search (with examples)
  • Tech stack and implementation outline
  • How tags are generated
  • Demo and source code links

App Overview

This web tool searches images that already have tag metadata and supports multi-tag queries.

Features:

  • AND filtering with multiple tags
  • Negative (exclude) tags like -long_hair
  • No database required — works on files in a local folder
  • Backend: C++ | Frontend: simple HTML

Examples

Note: The following images are style-modified versions of the original search results using ChatGPT’s image transformation, to avoid copyright issues.

Miko + Blonde Hair + 1 Girl

miko, 1girl, blonde_hair
Enter fullscreen mode Exit fullscreen mode

2025年8月6日 00_27_42.png

Miko but exclude Long Hair and Black Hair

miko, -long_hair, -black_hair
Enter fullscreen mode Exit fullscreen mode

2025年8月6日 00_33_00.png


Advanced Search Options

Find images where the blonde_hair score ≥ 0.8

blonde_hair:0.8
Enter fullscreen mode Exit fullscreen mode

Miko + Blonde Hair (≥ 0.9) + exclude Long Hair

miko, blonde_hair:0.9, -long_hair
Enter fullscreen mode Exit fullscreen mode

Exclude images with high explicitness

miko, -explicit:0.3
Enter fullscreen mode Exit fullscreen mode

How Tag Data Is Generated (img2tags + JSON)

Tags are generated automatically with the Python tool img2tags.
It uses a DeepDanbooru-style ViT model and outputs nested JSON containing tags and scores per image.

Example output:

{
    "tags": {
        "9": {
            "general": 0.9189,
            "sensitive": 0.1126,
            "questionable": 0.0131,
            "explicit": 0.0193
        },
        "0": {
            "simple_background": 0.7185,
            "english_text": 0.6080,
            "no_humans": 0.5793,
            "parody": 0.8484,
            "black_background": 0.9437,
            "title_parody": 0.5970,
            "blending": 0.8171,
            "logo_parody": 0.5945
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Where:

  • "tags" — root of the structure
  • "9"rating-related category (general, explicit, etc.)
  • "0"general tags (character, attributes, background, etc.)
  • Each tag has a score in [0.0, 1.0]

Demo & Source Code


Technical Notes

  • Backend: simple HTTP server written in C++
  • No DB: images + tag JSON files on disk are enough
  • Frontend: HTML + JavaScript (simple search form)
  • Negative tags supported (NOT filtering)
  • Results rendered as an image grid

Roadmap

  • Tag auto-completion & fuzzy search
  • UX improvements (lazy loading)
  • Simple UI for tag editing/fixes
  • Optional SQLite for larger datasets

Closing

If you want to organize your image collection and quickly pull things up by tags, this is handy.
I also hope it’s a useful reference for anyone who wants to try a small web tool in C++.

Top comments (1)

Collapse
 
regbee profile image
Regbee

Great idea, I like it!