animetimm/danbooru-wdtagger-v4-w640-ws-full
Updated • 217 • 7
How to use just-a-try/cls-dbv4-full.rotate.caformer_s36 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="just-a-try/cls-dbv4-full.rotate.caformer_s36", trust_remote_code=True)
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("just-a-try/cls-dbv4-full.rotate.caformer_s36", trust_remote_code=True, dtype="auto")r0, r90, r180, r270| # | Acc / Top-2 | Macro (F1/P/R/AUC) | Micro (F1/P/R/AUC) |
|---|---|---|---|
| Validation | 98.93% / 99.80% | 0.989 / 0.989 / 0.989 / 1.000 | 0.989 / 0.989 / 0.989 / 1.000 |
| Test | 98.97% / 99.81% | 0.990 / 0.990 / 0.990 / 1.000 | 0.990 / 0.990 / 0.990 / 1.000 |
We provided a sample image for our code samples, you can find it here.
Install dghs-imgutils, timm and other necessary requirements with the following command
pip install 'dghs-imgutils>=0.19.0' torch huggingface_hub timm pillow 'transformers>=4.57.1'
After that you can load this model with timm library, and use it for train, validation and test, with the following code
import torch
from imgutils.data import load_image
from transformers import AutoImageProcessor, AutoModel
processor = AutoImageProcessor.from_pretrained('just-a-try/cls-dbv4-full.rotate.caformer_s36', trust_remote_code=True)
model = AutoModel.from_pretrained('just-a-try/cls-dbv4-full.rotate.caformer_s36', trust_remote_code=True, use_infer_head=True)
model.eval()
image = load_image('https://huggingface.co/just-a-try/cls-dbv4-full.rotate.caformer_s36/resolve/main/sample.webp', mode='RGB', force_background='white')
input_ = processor(image)['pixel_values']
# input_, shape: torch.Size([1, 3, 384, 384]), dtype: torch.float32
classes = model.config.classes
# ['r0', 'r90', 'r180', 'r270']
with torch.no_grad():
output = model(input_)
# output, shape: torch.Size([1, 4]), dtype: torch.float32
print(dict(zip(classes, output[0].tolist())))
# {'r0': 0.012189035303890705,
# 'r90': 0.0006545081851072609,
# 'r180': 0.0038451426662504673,
# 'r270': 0.9833112955093384}
@misc{cls_dbv4_full_rotate_caformer_s36,
title = {Anime Classifier just-a-try/cls-dbv4-full.rotate.caformer_s36},
author = {narugo1992 and Deep Generative anime Hobbyist Syndicate (DeepGHS)},
year = {2025},
howpublished = {\url{https://huggingface.co/just-a-try/cls-dbv4-full.rotate.caformer_s36}},
note = {A anime-style image classification model for classification task with 4 classes (r0, r90, r180, r270), trained on anime dataset dbv4-full (\url{https://huggingface.co/datasets/animetimm/danbooru-wdtagger-v4-w640-ws-full}). Model parameters: 37.3M, FLOPs: 44.3G, input resolution: 384×384.},
license = {mit}
}
Base model
timm/caformer_s36.sail_in22k_ft_in1k_384