You need to agree to share your Hugging Face information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

deepghs-cv/bangumibase-face-quality-cls

A 4-class anime face drawing-quality classification dataset (88,000 single-character close-up frames, 818 anime shows), derived from deepghs/bangumibase-webp-4Mpixel_x. Labels are {poor, ok, good, excellent} from face_geo_mean = sqrt(face_w · face_h) after a strict single-face + single-head + face∩head-overlap consistency filter.

⚠ Scope. Every row is a frame from an anime TV-series broadcast. The dataset is intended for training/evaluating quality classifiers on the anime broadcast-frame domain only. It is not representative of illustrations, manga panels, fan art, AI-generated images, live-action photos, or any non-frame domain — classifiers trained here will degrade on those distributions. The 4-class label is the relative drawing fidelity within the broadcast anime-frame distribution (lower = small / rough faces typical of wide shots or low budget; higher = sharp close-ups).

Format is animetrans-native: WebDataset tar shards, per-row JSON sidecar with class key, classes.json at repo root. Loads via datasets.load_dataset(repo_id) and trains directly with animetrans.classification.train -ds <repo> -ck class.

class examples

Filter chain

step rule rows
0 raw table.parquet 4,535,936
1 has_face 4,525,126
2 face_count == 1 per source frame 4,493,744
3 face_aspect ≤ 2.5 4,439,094
4 min(width, height) ≥ 360 4,230,410
5 head_count == 1 (dghs-imgutils head_detect_v2.0_s, conf 0.4, iou 0.7) 4,055,230
6 area(face ∩ head) / area(face) ≥ 0.8 4,042,089
7 0.93-tight embedding-cluster dedup 2,789,339
8 balanced subsample (4 × 22,000, stratified by anime) 88,000

Filter 6 uses face_inside_head rather than IoU because anime characters' heads (hair, accessories) often extend well beyond the face — a 0.8 fraction-of-face-inside-head threshold catches the different-character failure mode while tolerating the legitimate head-much-larger-than-face case.

Class × split distribution

class train validation test all
0 (poor) 17,600 2,200 2,200 22,000
1 (ok) 17,600 2,200 2,200 22,000
2 (good) 17,600 2,200 2,200 22,000
3 (excellent) 17,600 2,200 2,200 22,000
all 70,400 8,800 8,800 88,000

class distribution

Bias control

Two failure modes a quality-classification dataset has to defend against: (a) near-duplicate leakage between train and val/test, and (b) cross-class confounds that let the model identify the class label from features other than face quality.

Cross-split: zero near-duplicate leakage

Splits are determined by the 0.94-loose embedding cluster of each image (cluster members all share a split). On the 4.04 M v3 corpus the within-cluster pair counts are:

split scheme within-split pairs cross-split pairs leak rate
sha256(image_id) % 100 (legacy) 6,110,627 3,141,820 33.96%
sha256(cluster_th94_id) % 100 (this dataset) 9,252,447 0 0.00%

Adversarial logistic regression on the raw 1024-d wd-swinv2-v3 embeddings predicting split cannot beat chance:

  • full corpus, 5-fold CV AUC = 0.5036 ± 0.002
  • balanced 88 K, 5-fold CV AUC = 0.5152 ± 0.010

Per-split centroid cosine similarity > 0.999 (train↔val 0.999994, train↔test 0.999995). Per-anime split proportions deviate from (0.8, 0.1, 0.1) by mean L1 = 0.0193.

adv split classifier AUC per-anime split proportions

Cross-class: bias measured, not eliminated

Class identity should be predictable from embedding: face_geo_mean (the labeling signal) trivially correlates with composition. But spurious cross-class confounds (anime style, color palette) are minimized by:

  • strict per-anime stratification in each (class, split) cell (largest-remainder over 818 anime), so no class is dominated by a single show;
  • 0.93-tight dedup removes near-duplicate same-shot variants that would otherwise concentrate around specific stylistic clusters.

Pairwise cosine similarity of per-class embedding centroids on the balanced 88 K (cosine, higher = more similar):

poor ok good excellent
poor 1.0000 0.9817 0.9458 0.8978
ok 0.9817 1.0000 0.9852 0.9404
good 0.9458 0.9852 1.0000 0.9753
excellent 0.8978 0.9404 0.9753 1.0000

Adjacent classes (0↔1, 1↔2, 2↔3) sit at sim > 0.97; the farthest pair (poor ↔ excellent) at 0.898 — exactly the face-size signal we want the model to learn. The geometry tracks the labels rather than the anime / style axis.

per-class centroid heatmap

face_geo_mean histogram

JSON sidecar schema

Each row carries a JSON file alongside the webp. Fields:

key type meaning
id int original BangumiBase image id
class str one of poor / ok / good / excellent
class_id int 0..3 matching the order in classes.json
head_bbox [x0, y0, x1, y1] (float) head detector bbox in original image pixel coordinates (the webp is not resized)
image_size [W, H] (int) original image size in pixels

head_bbox + image_size let downstream training code apply head-aware augmentation (random-crop that always contains the head) — see next section.

Usage

from datasets import load_dataset
ds = load_dataset("deepghs-cv/bangumibase-face-quality-cls")
row = ds['train'][0]
row['webp']                  # PIL.Image (<= 4 Mpixel webp)
row['json']['class']         # 'poor' | 'ok' | 'good' | 'excellent'
row['json']['class_id']      # 0..3
row['json']['head_bbox']     # [x0, y0, x1, y1] float, original-image px
row['json']['image_size']    # [W, H] int

Baseline training (no head-aware aug):

accelerate launch -m animetrans.classification.train \
    -ds deepghs-cv/bangumibase-face-quality-cls \
    -ck class \
    -m caformer_s36.sail_in22k_ft_in1k_384 \
    -bs 64 -mep 30 -lr 1e-4 -as 512

Reference baseline: deepghs-cv/cls-bangumibase-face-quality.caformer_s36 (val macro_f1 0.900, test macro_f1 0.898, test top-2 0.998).

Why head-aware augmentation matters: the framing shortcut

Class labels are derived from face_geo_mean = sqrt(face_w · face_h) in the original frame's pixel coordinates, so by construction poor / ok rows tend to be wide shots (small head-area fraction) while excellent rows tend to be close-ups (large head-area fraction). Without intervention, a classifier can hit very high accuracy by reading how much of the frame the head occupies instead of the face's intrinsic drawing quality.

To diagnose this, we randomly crop each test image so the head bbox is fully contained, but per-side margin is uniform in [0, max_margin × head_dim]. full keeps the original frame, then we tighten through loose_4x, loose_2x, ..., loose_0.25x down to head_only (exactly the head bbox). On the same 8,800 test rows and the same crops (paired), we ran two models trained on this dataset:

Result (macro_f1 on the test split):

crop setting margin × head baseline head_crop Δ
full (in-distribution) — 0.9197 0.9204 +0.001
loose_4x 4.0 0.6258 0.9280 +0.302
loose_2x 2.0 0.5328 0.9296 +0.397
loose_1x 1.0 0.4403 0.9356 +0.495
loose_0.5x 0.5 0.3706 0.9350 +0.564
loose_0.25x 0.25 0.3200 0.9348 +0.615
head_only 0.0 0.2492 0.9328 +0.684

baseline vs head_crop crop-robustness

Reading the figure:

  • The baseline (blue, left chart) collapses to the 4-class chance line (0.25) as the frame context is removed — it identifies most poor / ok rows entirely from how small the head is in the frame. Per-class F1 on head_only: poor 0.05, ok 0.01 (right chart, solid lines).
  • The head_crop model (red) holds macro_f1 ≈ 0.93 across all 7 crop settings, with per-class F1 staying above 0.89 even on head_only (right chart, dashed lines). It learned face-intrinsic features, not framing.
  • Both models report nearly identical macro_f1 on the original full frames (0.920 vs 0.920) — the augmentation costs nothing in in-distribution accuracy.

The augmentation samples a random axis-aligned crop that fully contains the head bbox; per-side extra context is uniform in [0, max_margin × head_dim]. The head_bbox field on every row of this dataset is what makes this possible. See the Head-aware training (recommended) section below for the drop-in row-level processor and CLI wrapper.

Head-aware training (recommended)

A drop-in row-level processor (head_crop) plus a thin CLI wrapper are published with the reference pipeline (scripts/rtp_head_crop.py, scripts/train_with_head_crop.py). No edits to animetrans itself.

Sketch:

# scripts/rtp_head_crop.py
from animetrans.rtp.base import RowLevelProcessor, register_rprocessor
@register_rprocessor('classification', 'head_crop')
class HeadCropAugProcessor(RowLevelProcessor):
    def on_train(self, image, json_):
        cropped = random_crop_containing_head(
            image, json_['head_bbox'], max_margin_factor=4.0)
        return cropped, json_
    # eval / test path is the parent class identity -- frames untouched
# scripts/train_with_head_crop.py imports the rtp module, then calls
# animetrans.classification.train.cli.
accelerate launch --num_processes 4 --mixed_precision bf16 \
    scripts/train_with_head_crop.py \
    -ds deepghs-cv/bangumibase-face-quality-cls \
    -rtp head_crop \
    -ck class \
    -m caformer_s36.sail_in22k_ft_in1k_384 \
    -bs 64 -mep 30 -lr 1e-4 -as 512 \
    -w runs/bbfq-v3-head-crop

Hyperparameters via env vars: HEAD_CROP_MAX_MARGIN (default 4.0), HEAD_CROP_MIN_MARGIN (0.0), HEAD_CROP_P_FULL (0.10 -- fraction of train batches that stay uncropped, to keep the original distribution represented).

Validation and test inputs pass through unchanged, so reported metrics remain directly comparable to the baseline above.

License

Source frames inherit the BangumiBase license (other). Labels are MIT.

Downloads last month
5

Models trained or fine-tuned on deepghs-cv/bangumibase-face-quality-cls

Space using deepghs-cv/bangumibase-face-quality-cls 1