/ Модель

Характеристики

Лицензия
GPL 3.0
Архитектура
pytorch · dense
Опубликована
28 фев 2025

camie-tagger

Классификация изображенийИзображение → label3 профессии

Camie Tagger классифицирует аниме- и манга-иллюстрации и присваивает им теги персонажей, произведений, художников и других категорий.

110скачиваний за 30 дней66лайковвеса обновлены31 авг 2025

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Camie Tagger — модель классификации изображений для автоматической разметки аниме- и манга-иллюстраций. По README, автор обучил её на наборе из 7 024 392 примеров; модель предсказывает до 70 527 тегов из семи категорий: общие теги, персонажи, произведения, художники, метаданные, рейтинг и год. В архитектуре используются EfficientNetV2-L, слой эмбеддингов и перекрёстное внимание для уточнения предсказаний. README указывает размеры начальной и уточнённой моделей — 214 млн и 424 млн параметров — и микросредний F1 58,1% на тесте из 20 116 примеров.

Модель предназначена для автоматического тегирования иллюстраций и получения категорийных меток с настраиваемыми порогами. Особенно хорошо, по словам автора, она предсказывает теги персонажей и произведений; метрики для редких тегов и общих категорий скромнее, а обучение автор характеризует как незавершённое. Для содержимого с рейтингом предусмотрена отдельная категория, но README не заявляет, что модель генерирует изображения. Репозиторий предоставляет веса в форматах Safetensors и ONNX; лицензия — GPL-3.0.

Сценарии применения

  • автоматическое тегирование аниме-иллюстраций
  • поиск персонажей на изображениях
  • определение названия произведения по иллюстрации
  • распознавание имени художника по изображению
  • присвоение общих тегов и метаданных иллюстрации
  • классификация изображений по категории рейтинга

Ограничения

В README указаны скромные показатели для редких и общих тегов: 31,5% macro F1; автор считает модель недообученной. Результат зависит от выбора порогов и профиля предсказаний.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Camie Tagger

An advanced deep learning model for automatically tagging anime/manga illustrations with relevant tags across multiple categories, achieving 58.1% micro F1 score (31.5% macro F1 score using the balanced threshold preset) across 70,527 possible tags on a test set of 20,116 samples. Trained on a single 3060.

🚀 Updates (August 2025)

Camie-tagger-v2 is out! https://huggingface.co/Camais03/camie-tagger-v2

🔑 Key Highlights

  • Efficient Training: Completed on just a single RTX 3060 GPU (12GB VRAM)
  • Fast Convergence: Trained on 7,024,392 samples (3.52 epochs) in 1,756,098 batches
  • Comprehensive Coverage: 70,527 tags across 7 categories (general, character, copyright, artist, meta, rating, year)
  • Innovative Architecture: Two-stage prediction model with EfficientNetV2 backbone, Embedding layer and cross-attention for tag context
  • Model Size: Initial model (214M parameters), Refined model (424M parameters)
  • User-Friendly Interface: Easy-to-use application with customizable thresholds

This project demonstrates that high-quality anime image tagging models can be trained on consumer hardware with the right optimization techniques.

✨ Features

  • Multi-category tagging system: Handles general tags, characters, copyright (series), artists, meta information, and content ratings
  • High performance: 53.4% micro F1 score (31.5% macro F1) across 70,527 possible tags
  • Windows compatibility: Initial-only mode works on Windows without Flash Attention
  • Streamlit web interface: User-friendly UI for uploading and analyzing images and a tag collection game
  • Adjustable threshold profiles: Micro, Macro, Balanced, Category-specific, High Precision, and High Recall profiles
  • Fine-grained control: Per-category threshold adjustments for precision-recall tradeoffs
  • Safetensors and ONNX: Original pickle files available in /models
  • EfficientNetV2-L Backbone: Backbone performance greatly improved by the refining embedding layer

📊 Performance Notes

The performance seems a little underwhelming when looking at macro scores especially for general tags (check tables in performance section). However I've found that the model is still generally good at predicting these tags and is very good at character and copyright tags. It's also the case that there are just so many tags to predict.

The good news is that the model shows clear evidence of being undertrained, with consistent improvement across training epochs:

Training Progress (Micro vs Macro F1):
Epoch 2:   Micro-F1: 0.595    Macro-F1: 0.226  
Epoch 3:   Micro-F1: 0.606    Macro-F1: 0.268 (+4.2%)
Epoch 3.5: Micro-F1: 0.611    Macro-F1: 0.290 (+2.2% only 0.5 epochs)

This makes sense as 3.5 epochs really isn't alot of training time at all.

Micro vs Macro F1 Explained:

  • Micro-F1: Calculates metrics globally by considering each tag instance prediction. This metric is dominated by common tags and categories with many examples.
  • Macro-F1: Calculates metrics for each tag independently then averages them. This gives equal weight to rare tags and common tags.

The significant improvement in Macro-F1 (+4% per epoch) suggests that longer training would especially benefit rare tag recognition, while Micro-F1 improvements are slowing down as common tags are already well-learned.

Future Training Plans

I plan to continue training the model to further improve performance, especially for rare tags. However, each epoch takes approximately 1.5-2 weeks of overnight training on my current hardware.

If you'd like to support further training on the complete dataset or my future projects, consider supporting me here:(https://ko-fi.com/camais). Your support will directly enable longer training runs and better models!

After this project, I plan to move onto LLMs as I have lots of ideas on how to improve upon them. I will update this model based on community attention.

📈 Performance Analysis

Overall Performance

INITIAL PREDICTIONS

CATEGORYPROFILETHRESHOLDMICRO-F1MACRO-F1
overallMICRO OPT0.3260.6110.290
MACRO OPT0.2010.5340.331
BALANCED0.2580.5810.315
HIGH PRECISION0.5000.4970.163
HIGH RECALL0.1200.3080.260
artistMICRO OPT0.2620.4740.295
MACRO OPT0.1400.2620.287
BALANCED0.2580.4740.298
HIGH PRECISION0.4640.3100.135
HIGH RECALL0.1530.3020.301
characterMICRO OPT0.2940.7490.444
MACRO OPT0.1610.6080.517
BALANCED0.2580.7460.478
HIGH PRECISION0.5000.6550.268
HIGH RECALL0.1000.3360.386
copyrightMICRO OPT0.3340.7890.325
MACRO OPT0.2050.7000.404
BALANCED0.2580.7630.377
HIGH PRECISION0.5000.7470.209
HIGH RECALL0.1000.3470.267
generalMICRO OPT0.3220.6070.180
MACRO OPT0.2250.5370.210
BALANCED0.2580.5760.204
HIGH PRECISION0.5000.4820.095
HIGH RECALL0.1240.3010.161
metaMICRO OPT0.3300.6010.134
MACRO OPT0.2090.4870.143
BALANCED0.2580.5570.144
HIGH PRECISION0.5000.4580.081
HIGH RECALL0.1200.3090.103
ratingMICRO OPT0.3590.8080.791
MACRO OPT0.3590.8080.791
BALANCED0.2580.7790.768
HIGH PRECISION0.5000.7380.686
HIGH RECALL0.1000.6500.611
yearMICRO OPT0.2660.3320.285
MACRO OPT0.2580.3310.286
BALANCED0.2580.3310.286
HIGH PRECISION0.3020.3080.251
HIGH RECALL0.2130.3040.279

REFINED PREDICTIONS

CATEGORYPROFILETHRESHOLDMICRO-F1MACRO-F1
overallMICRO OPT0.3260.6130.295
MACRO OPT0.1930.5460.338
BALANCED0.2620.5860.326
HIGH PRECISION0.5000.4990.173
HIGH RECALL0.1200.3100.262
artistMICRO OPT0.2780.4800.297
MACRO OPT0.1480.2880.299
BALANCED0.2620.4830.311
HIGH PRECISION0.4800.3140.140
HIGH RECALL0.1530.3020.306
characterMICRO OPT0.3020.7570.460
MACRO OPT0.1570.5910.524
BALANCED0.2620.7510.496
HIGH PRECISION0.5000.6690.286
HIGH RECALL0.1000.3310.386
copyrightMICRO OPT0.3670.7920.317
MACRO OPT0.1890.6710.419
BALANCED0.2620.7670.392
HIGH PRECISION0.4920.7550.228
HIGH RECALL0.1000.3490.270
generalMICRO OPT0.3260.6080.181
MACRO OPT0.2370.5530.215
BALANCED0.2620.5800.208
HIGH PRECISION0.5000.4840.100
HIGH RECALL0.1240.3030.165
metaMICRO OPT0.3300.6020.127
MACRO OPT0.1970.4680.145
BALANCED0.2620.5630.152
HIGH PRECISION0.5000.4530.087
HIGH RECALL0.1200.3050.107
ratingMICRO OPT0.3750.8080.787
MACRO OPT0.3380.8090.795
BALANCED0.2620.7840.773
HIGH PRECISION0.5000.7350.678
HIGH RECALL0.1000.6520.610
yearMICRO OPT0.2660.3320.292
MACRO OPT0.2580.3310.293
BALANCED0.2620.3330.293
HIGH PRECISION0.3060.3060.255
HIGH RECALL0.2090.3010.275

The model performs particularly well on character identification (75.7% F1 across 26,968 tags), copyright/series detection (79.2% F1 across 5,364 tags), and content rating classification (80.8% F1 across 4 tags).

Initial vs. Refined Prediction Performance

PREDICTION TYPEMICRO-F1MACRO-F1PRECISIONRECALL
INITIAL0.6110.2900.6100.613
REFINED0.6130.2950.6170.609

Refinement improves Micro-F1 by +0.2% and Macro-F1 by +0.5%. As shown, the refined predictions offer a small but consistent improvement over the initial predictions, making the Initial-only model a good choice for Windows users where Flash Attention isn't available.

Real-world Tag Accuracy

In personal testing, I've observed that many "false positives" according to the benchmark are actually correct tags that were missing from the Danbooru dataset (which itself is not 100% perfectly tagged). Some observations:

  • For character, copyright, and artist categories, the top predicted tag is frequently correct even when the model isn't highly confident.
  • Many seemingly incorrect general tags are actually appropriate descriptors that were simply not included in the original tagging.

For these reasons, the High Recall threshold profile may produce better perceived results in practice despite a lower formal F1 score. When using the application, limiting the output to the top N tags per category can deliver the most accurate and useful results.

Comparison to WDTaggers:

It's a little tricky to compare our taggers for two reasons: The amount of tags 70,000+ for mine and 10,000+ for WD. I only kept samples with at least 25 general tags (and at least 1 character+copyright tag) vs at least 10 for WD. This means my samples on average have 44.74 mean tags per sample against WD taggers 36.48 in my own testing. That is a difference of 18.5%.

Keeping that in mind for the current checkpoint I'd say that mine seems somewhat more accurate for rarer tags just because mine covers much more. WD is considerably more accurate for common tags.

Here is a comparison between the two taggers with the same number of tags: https://huggingface.co/datasets/SmilingWolf/camie-tagger-vs-wd-tagger-val

In my personal testing mine seems to be better at rarer characters, copyright, artists and some rare general tags getting alternative costumes and the artist etc. Camie tagger did seem to have a few 1-3 more false positives for the general tags however. Keep in mind this is with a couple of images so I could be wrong.

After a few more epochs I think the gap could be a lot smaller but it's going to be a month or so before that point while I let it train overnight. I think WD tagger was trained for 50+ epochs with mine currently at 3.5.

Overall the distribution of tags is extremely long tailed. My game shows this with the rarity range. Most tags end up in the most rare category. Both taggers should give you good accuracy for the most common tags.

🛠️ Requirements

  • Python 3.11.9 specifically (newer versions are incompatible)
  • PyTorch 1.10+
  • Streamlit
  • PIL/Pillow
  • NumPy
  • Flash Attention (note: doesn't work properly on Windows only needed for refined model which I'm not supporting that much anyway)

🔧 Usage

Setup the application and game by executing setup.bat. This installs the required virtual environment:

  • Upload your own images or select from example images
  • Choose different threshold profiles
  • Adjust category-specific thresholds
  • View predictions organized by category
  • Filter and sort tags based on confidence

Use run_app.bat and run_game.bat.

🎮 Tag Collector Game (Camie Collector)

Introducing a Tagging game - a gamified approach to anime image tagging that helps you understand the performance and limits of the model. This was a shower thought gone to far! Lots of Project Moon references.

How to Play:

  1. Upload an image
  2. Scan for tags to discover them Collect Tags Tab
  3. Earn TagCoins for new discoveries
  4. Spend TagCoins on upgrades to lower the threshold Upgrades Tab
  5. Lower thresholds reveal rarer tags!
  6. Collect sets of related tags for bonuses and reveal unique mosaics! Mosaics Tab
  7. Visit the Library System to discover unique tags (not collect) Library Tab
  8. Use collected tags to either inspire new searches or generate essence
  9. Use Enkephalin to generate Tag Essences Essence Tab
  10. Use the Tag Essence Generator to collect the tag and related tags to it. Lamp Essence: Lamp Essence

🖥️ Web Interface Guide

The interface is divided into three main sections:

  1. Model Selection (Sidebar):

    • Choose between Full Model, Initial-only Model or ONNX accelerated (initial only)
    • View model information and memory usage
  2. Image Upload (Left Panel):

    • Upload your own images or select from examples
    • View the selected image
  3. Tagging Controls (Right Panel):

    • Select threshold profile
    • Adjust thresholds for precision-recall and micro/macro tradeoff
    • Configure display options
    • View predictions organized by category

Display Options:

  • Show all tags: Display all tags including those below threshold
  • Compact view: Hide progress bars for cleaner display
  • Minimum confidence: Filter out low-confidence predictions
  • Category selection: Choose which categories to include in the summary

Interface Screenshots:

Application Interface

Tag Results Example

🧠 Training Details

Dataset

The model was trained on a carefully filtered subset of the Danbooru 2024 dataset, which contains a vast collection of anime/manga illustrations with comprehensive tagging.

Filtering Process:

The dataset was filtered with the following constraints:

# Minimum tags per category required for each image
min_tag_counts = {
    'general': 25, 
    'character': 1, 
    'copyright': 1, 
    'artist': 0, 
    'meta': 0
}

# Minimum samples per tag required for tag to be included
min_tag_samples = {
    'general': 20, 
    'character': 40, 
    'copyright': 50, 
    'artist': 200, 
    'meta': 50
}

This filtering process:

  1. First removed low-sample tags (tags with fewer occurrences than specified in min_tag_samples)
  2. Then removed images with insufficient tags per category (as specified in min_tag_counts)

Training Data:

  • Starting dataset size: ~3,000,000 filtered images
  • Training subset: 2,000,000 images (due to storage and time constraints)
  • Training duration: 3.5 epochs

Preprocessing:

Images were preprocessed with minimal transformations:

  • Tensor normalization (scaled to 0-1 range)
  • Resized while maintaining original aspect ratio
  • No additional augmentations were applied

Loss Function

The model employs a specialized UnifiedFocalLoss to address the extreme class imbalance inherent in multi-label tag prediction:

class UnifiedFocalLoss(nn.Module):
    def __init__(self, device=None, gamma=2.0, alpha=0.25, lambda_initial=0.4):
        # Implementation details...

Key Components:

  1. Focal Loss Mechanism:

    • Down-weights well-classified examples (γ=2.0) to focus training on difficult tags
    • Addresses the extreme imbalance between positive and negative examples (often 100:1 or worse)
    • Uses α=0.25 to balance positive/negative examples across 70,527 possible tags
  2. Two-stage Weighting:

    • Combines losses from both prediction stages (initial_predictions and refined_predictions)
    • Uses λ=0.4 to weight the initial prediction loss, giving more importance (0.6) to refined predictions
    • This encourages the model to improve predictions in the refinement stage while still maintaining strong initial predictions
  3. Per-sample Statistics:

    • Tracks separate metrics for positive and negative samples
    • Provides detailed debugging information about prediction distributions
    • Enables analysis of which tag categories are performing well/poorly

This loss function was essential for achieving high F1 scores across diverse tag categories despite the extreme classification challenge of 70,527 possible tags.

DeepSpeed Configuration

Microsoft DeepSpeed was crucial for training this model on consumer hardware. The project uses a carefully tuned configuration to maximize efficiency:

def create_deepspeed_config(
    config_path,
    learning_rate=3e-4,
    weight_decay=0.01,
    num_train_samples=None,
    micro_batch_size=4,
    grad_accum_steps=8
):
    # Implementation details...

Key Optimizations:

  1. Memory Efficiency:

    • ZeRO Stage 2: Partitions optimizer states and gradients, dramatically reducing memory requirements
    • Activation Checkpointing: Trades computation for memory by recomputing activations during backpropagation
    • Contiguous Memory Optimization: Reduces memory fragmentation
  2. Mixed Precision Training:

    • FP16 Mode: Uses half-precision (16-bit) for most calculations, with automatic loss scaling
    • Initial Scale Power: Set to 16 for stable convergence with large batch sizes
  3. Gradient Accumulation:

    • Micro-batch size of 4 with 8 gradient accumulation steps
    • Effective batch size of 32 while only requiring memory for 4 samples at once
  4. Learning Rate Schedule:

    • WarmupLR scheduler with gradual increase from 3e-6 to 3e-4
    • Warmup over 1/4 of an epoch to stabilize early training

This configuration allowed the model to train efficiently with only 12GB of VRAM while maintaining numerical stability across millions of training examples with 70,527 output dimensions.

Model Architecture

The model uses a novel two-stage prediction approach that achieves superior performance compared to traditional single-stage models:

Image Feature Extraction:

  • Backbone: EfficientNet V2-L extracts high-quality visual features from input images
  • Spatial Pooling: Adaptive averaging converts spatial features to a compact 1280-dimensional embedding

Initial Prediction Stage:

  • Direct classification from image features through a multi-layer classifier
  • Bottleneck architecture with LayerNorm and GELU activations between linear layers
  • Outputs initial tag probabilities across all 70,527 possible tags
  • Model size: 214,657,273 parameters

Tag Context Mechanism:

  • Top predicted tags are embedded using a shared embedding space
  • Self-attention layer allows tags to influence each other based on co-occurrence patterns
  • Normalized tag embeddings represent a coherent "tag context" for the image

Cross-Attention Refinement:

  • Image features and tag embeddings interact through cross-attention
  • Each dimension of the image features attends to relevant dimensions in the tag space
  • This creates a bidirectional flow of information between visual features and semantic tags

Refined Predictions:

  • Fused features (original + cross-attended) feed into a final classifier
  • Residual connection ensures initial predictions are preserved when beneficial
  • Temperature scaling provides calibrated probability outputs
  • Total model size: 424,793,720 parameters

This dual-stage approach allows the model to leverage tag co-occurrence patterns and semantic relationships, improving accuracy without increasing the parameter count significantly.

Model Details

Tag Categories:

The model recognizes tags across these categories:

  • General: Visual elements, concepts, clothing, etc. (30,841 tags)
  • Character: Individual characters appearing in the image (26,968 tags)
  • Copyright: Source material (anime, manga, game) (5,364 tags)
  • Artist: Creator of the artwork (7,007 tags)
  • Meta: Meta information about the image (323 tags)
  • Rating: Content rating (4 tags)
  • Year: Year of upload (20 tags)

All supported tags are stored in model/metadata.json, which maps tag IDs to their names and categories.

💻 Training Environment

The model was trained using surprisingly modest hardware:

  • GPU: Single NVIDIA RTX 3060 (12GB VRAM)
  • RAM: 64GB system memory
  • Platform: Windows with WSL (Windows Subsystem for Linux)
  • Libraries:
    • Microsoft DeepSpeed for memory-efficient training
    • PyTorch with CUDA acceleration
    • Flash Attention for optimized attention computation

Training Notebooks

The repository includes two main training notebooks:

  1. CAMIE Tagger.ipynb:

    • Main training notebook
    • Dataset loading and preprocessing
    • Model initialization
    • Initial training loop with DeepSpeed integration
    • Tag selection optimization
    • Metric tracking and visualization
  2. Camie Tagger Cont and Evals.ipynb:

    • Continuation of training from checkpoints
    • Comprehensive model evaluation
    • Per-category performance metrics
    • Threshold optimization
    • Model conversion for deployment in the app
    • Export functionality for the standalone application

Training Monitor

The project includes a real-time training monitor accessible via browser at localhost:5000 during training:

Performance Tips:

⚠️ Important: For optimal training speed, keep VSCode minimized and the training monitor open in your browser. This can improve iteration speed by 3-5x due to how the Windows/WSL graphics stack handles window focus and CUDA kernel execution.

Monitor Features:

The training monitor provides three main views:

1. Overview Tab:

Overview Tab

  • Training Progress: Real-time metrics including epoch, batch, speed, and time estimates
  • Loss Chart: Training and validation loss visualization
  • F1 Scores: Initial and refined F1 metrics for both training and validation
2. Predictions Tab:

Predictions Tab

  • Image Preview: Shows the current sample being analyzed
  • Prediction Controls: Toggle between initial and refined predictions
  • Tag Analysis:
    • Color-coded tag results (correct, incorrect, missing)
    • Confidence visualization with probability bars
    • Category-based organization
    • Filtering options for error analysis
3. Selection Analysis Tab:

Selection Analysis Tab

  • Selection Metrics: Statistics on tag selection quality
    • Ground truth recall
    • Average probability for ground truth vs. non-ground truth tags
    • Unique tags selected
  • Selection Graph: Trends in selection quality over time
  • Selected Tags Details: Detailed view of model-selected tags with confidence scores

The monitor provides invaluable insights into how the two-stage prediction model is performing, particularly how the tag selection process is working between the initial and refined prediction stages.

Training Notes:

  • Training notebooks require WSL and likely 32GB+ of RAM to handle the dataset
  • Microsoft DeepSpeed was crucial for fitting the model and batches into the available VRAM
  • Despite hardware limitations, the model achieves impressive results
  • With more computational resources, the model could be trained longer on the full dataset

🙏 Acknowledgments

  • Claude Sonnet 3.5 and 3.7 for being incredibly helpful with the brainstorming and coding
  • EfficientNetV2 for the backbone
  • Danbooru for the incredible dataset of tagged anime images
  • p1atdev for the processed Danbooru 2024 dataset
  • Microsoft for DeepSpeed, which made training possible on consumer hardware
  • PyTorch and the open-source ML community

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

Архитектура pytorch неизвестна transformers в образе рантайма.

Ревизия весов
9afb19b

0 моделей