Views
No views yet
| # | Macro@0.40 (F1/MCC/P/R) | Micro@0.40 (F1/MCC/P/R) | Macro@Best (F1/P/R) |
|---|---|---|---|
| Validation | 0.580 / 0.584 / 0.626 / 0.556 | 0.697 / 0.696 / 0.692 / 0.701 | --- |
| Test | 0.580 / 0.584 / 0.627 / 0.556 | 0.697 / 0.696 / 0.693 / 0.702 | 0.611 / 0.612 / 0.630 |
Macro/Micro@0.40 means the metrics on the threshold 0.40.Macro@Best means the mean metrics on the tag-level thresholds on each tags, which should have the best F1 scores.| Category | Name | Alpha | Threshold | Micro@Thr (F1/P/R) | Macro@0.40 (F1/P/R) | Macro@Best (F1/P/R) |
|---|---|---|---|---|---|---|
| 0 | general | 1 | 0.38 | 0.685 / 0.673 / 0.697 | 0.457 / 0.514 / 0.430 | 0.494 / 0.490 / 0.524 |
| 4 | character | 1 | 0.51 | 0.946 / 0.962 / 0.930 | 0.930 / 0.948 / 0.915 | 0.943 / 0.959 / 0.930 |
| 9 | rating | 1 | 0.24 | 0.828 / 0.790 / 0.871 | 0.833 / 0.823 / 0.843 | 0.835 / 0.812 / 0.861 |
Micro@Thr means the metrics on the category-level suggested thresholds, which are listed in the table above.Macro@0.40 means the metrics on the threshold 0.40.Macro@Best means the metrics on the tag-level thresholds on each tags, which should have the best F1 scores.pip install 'dghs-imgutils>=0.19.0' torch huggingface_hub timm pillow pandas1import json
2
3import pandas as pd
4import torch
5from huggingface_hub import hf_hub_download
6from imgutils.data import load_image
7from imgutils.preprocess import create_torchvision_transforms
8from timm import create_model
9
10repo_id = 'animetimm/convnextv2_huge.dbv4-full'
11model = create_model(f'hf-hub:{repo_id}', pretrained=True)
12model.eval()
13
14with open(hf_hub_download(repo_id=repo_id, repo_type='model', filename='preprocess.json'), 'r') as f:
15 preprocessor = create_torchvision_transforms(json.load(f)['test'])
16# Compose(
17# PadToSize(size=(512, 512), interpolation=bilinear, background_color=white)
18# Resize(size=(512, 512), interpolation=bicubic, max_size=None, antialias=True)
19# CenterCrop(size=[512, 512])
20# MaybeToTensor()
21# Normalize(mean=tensor([0.4850, 0.4560, 0.4060]), std=tensor([0.2290, 0.2240, 0.2250]))
22# )
23
24image = load_image('https://huggingface.co/animetimm/convnextv2_huge.dbv4-full/resolve/main/sample.webp')
25input_ = preprocessor(image).unsqueeze(0)
26# input_, shape: torch.Size([1, 3, 512, 512]), dtype: torch.float32
27with torch.no_grad():
28 output = model(input_)
29 prediction = torch.sigmoid(output)[0]
30# output, shape: torch.Size([1, 12476]), dtype: torch.float32
31# prediction, shape: torch.Size([12476]), dtype: torch.float32
32
33df_tags = pd.read_csv(
34 hf_hub_download(repo_id=repo_id, repo_type='model', filename='selected_tags.csv'),
35 keep_default_na=False
36)
37tags = df_tags['name']
38mask = prediction.numpy() >= df_tags['best_threshold']
39print(dict(zip(tags[mask].tolist(), prediction[mask].tolist())))
40# {'sensitive': 0.9900546073913574,
41# '1girl': 0.9986221790313721,
42# 'solo': 0.9894072413444519,
43# 'looking_at_viewer': 0.8689708113670349,
44# 'blush': 0.8729097843170166,
45# 'smile': 0.9395995736122131,
46# 'short_hair': 0.6831153631210327,
47# 'long_sleeves': 0.6779903173446655,
48# 'brown_hair': 0.802174985408783,
49# 'holding': 0.3276722729206085,
50# 'dress': 0.6280677318572998,
51# 'sitting': 0.6450996994972229,
52# 'purple_eyes': 0.8072393536567688,
53# 'flower': 0.9524818062782288,
54# 'braid': 0.8764650225639343,
55# 'outdoors': 0.47000938653945923,
56# 'tears': 0.9879008531570435,
57# 'floral_print': 0.5994200706481934,
58# 'crying': 0.34614139795303345,
59# 'plant': 0.3870095908641815,
60# 'crown_braid': 0.7048561573028564,
61# 'happy_tears': 0.759681224822998,
62# 'pavement': 0.2870482802391052,
63# 'wiping_tears': 0.9898664951324463,
64# 'brick_floor': 0.5737900137901306}@misc{convnextv2_huge_dbv4_full,
title = {Anime Tagger convnextv2_huge.dbv4-full},
author = {narugo1992 and Deep Generative anime Hobbyist Syndicate (DeepGHS)},
year = {2025},
howpublished = {\url{https://huggingface.co/animetimm/convnextv2_huge.dbv4-full}},
note = {A large-scale anime-style image classification model based on convnextv2_huge architecture for multi-label tagging with 12476 tags, trained on anime dataset dbv4-full (\url{https://huggingface.co/datasets/animetimm/danbooru-wdtagger-v4-w640-ws-full}). Model parameters: 692.6M, FLOPs: 1.2T, input resolution: 512×512.},
license = {gpl-3.0}
}