Skip to content
ModelListedExternal
Download

Anime Style Classifier v6

An EfficientNet-B2 model that classifies anime frames into 5 production style categories, expanding on v5 by splitting the painterly class into distinct pencil-sketch and painterly substyles. It can also produce...

KindOtherBase modelefficientnet_b2VersionRevision 97466faBgrade

Model source

Kind
Other
File size
29.7 MB
Base model
efficientnet_b2
Version
vRevision 97466fa
Updated
Oct 10, 2026
Downloads
65
Source
Hugging Face

Source description

Anime Style Classifier v6

An EfficientNet-B2 model that classifies anime frames into 5 production style categories, expanding on v5 by splitting the painterly class into distinct pencil-sketch and painterly substyles. It can also produce 1,408-dimensional pooled feature embeddings for measuring visual similarity between frames. These embeddings are useful for style-oriented search, but are not guaranteed to be independent of image content.

Model Details

Architecture

EfficientNet-B2 (timm)

Parameters

7.7M

Input

440 × 440 RGB

Embedding dim

1,408 (global-average-pooled final feature map)

Classes

5 (flat, modern, retro, stylised_painterly, stylised_pencil)

Format

SafeTensors

File size

30 MB

Training data

97,444 images across 5 classes

Training method

Supervised ASL (Asymmetric Softmax) with batch-balanced sampling

Classes

StyleDescriptionExample Series
flatMinimal shading, solid color blocks, low gradientsPing Pong The Animation, Kaiba, The Heike Story
modernHigh-detail digital pipeline, clean gradients, AAA productionDemon Slayer, Violet Evergarden, Attack on Titan
retroCel-era aesthetic, grain, limited dynamic rangeCowboy Bebop, Neon Genesis Evangelion, Robotech
stylised_painterlyWatercolor/oil feel, visible brush texture, organic transitionsMushi-Shi, Your Lie in April, Land of the Lustrous
stylised_pencilSketch/pencil line art, loose strokes, minimalist shadingKill la Kill, Carole & Tuesday, Penguindrum

Style Examples

flatmodern
retrostylised_painterly

stylised_pencil |
---|--- |

Performance

OOD Evaluation (459 held-out images, never seen during training)

Overall accuracy: 96.30% (442/459)

ClassRecallCountErrors
flat98.6%73/741
modern99.0%204/2062
retro94.0%94/1006
stylised_painterly90.9%40/444
stylised_pencil88.6%31/354

Confusion Matrix

| → flat | → modern | → retro | → painterly | → pencil ---|---|---|---|---|--- flat (74) | 73 | 0 | 1 | 0 | 0 modern (206) | 2 | 204 | 0 | 0 | 0 retro (100) | 1 | 5 | 94 | 0 | 0 painterly (44) | 1 | 2 | 0 | 40 | 1 pencil (35) | 2 | 0 | 1 | 1 | 31

Error Analysis (17 total)

All errors are borderline cases. Click any thumbnail to view full size.

ImageTruePredictedConfidenceNotes
flatretro51.8%Cel-shaded chibi art resembles vintage style
modernflat70.6%Minimalist scene with almost no shading
retromodern94.3%High-confidence error — clean remaster
retromodern88.5%Muted palette but sharp compositing
stylised_painterlyflat92.0%AI-gen with minimal texture; reads as flat
stylised_painterlystylised_pencil96.0%Ink-wash with strong pencil line dominance
stylised_painterlymodern55.8%Synthetic frame; clean digital finish undermines painterly read
stylised_pencilretro49.8%Low-confidence; grainy scan resembles cel-era
stylised_pencilflat77.6%Clean lines with minimal visible stroke texture
stylised_pencilstylised_painterly56.3%Pastel wash over sketch — genuinely transitional

Comparison to V5 (4-class Baseline)

MetricV5 (4-class)V6 (5-class)Notes
Overall OOD98.41%96.30%−2.11pp (acceptable tradeoff for added granularity)
Flat100.0%98.6%−1.4pp
Modern98.5%99.0%+0.5pp ✓
Retro99.0%94.0%−5pp (hard class, cel-era mastered series)
Painterly (V5)94.0%90.9% / 88.6%V6 splits into painterly (90.9%) + pencil (88.6%)
Training Data19,61197,444+397% (larger dataset, same architecture)
ArchitectureSameSameEfficientNet-B2 @ 440px
Loss FunctionCross-entropy + mergeASL (Asymmetric Softmax)ASL delivers +8pp vs CE baseline

Why the Tradeoff?

V5's high accuracy (98.41% OOD) came from a small, highly-curated 19.6k image dataset and class-balanced sampling. V6 training expanded to 97.4k images across 5 classes to separate pencil and painterly:

  • Data imbalance: Retro has nearly 15× more training samples than flat (dataset-driven split, not architecture-driven)
  • Annotation subjectivity: The pencil class has 35 examples in the reported OOD benchmark (small sample size)
  • Boundary ambiguity: Pencil/painterly blend on 2-3% of training images (subjective human labels)

The 2.11pp OOD drop is acceptable given the added classification granularity. Pencil is the weakest class at 88.6%; the other reported class recalls range from 90.9% to 99.0%.

Shared Class Performance (V5 v6 split analysis)

For direct comparison, merging V6's painterly + pencil back into single "painterly" class:

  • V5 painterly: 94.0% (47/50 OOD)
  • V6 painterly+pencil merged: 90.6% (71/79 OOD)
  • Delta: −3.4pp (expected from increased training distribution mismatch)

Usage

Installation

pip install torch timm torchvision pillow

Classification

import torch
from safetensors.torch import load_file
import timm
from PIL import Image
from torchvision import transforms

# Load model
model = timm.create_model('efficientnet_b2', num_classes=5, pretrained=False)
state_dict = load_file('model.safetensors')
model.load_state_dict(state_dict)
model.eval()

# Preprocessing
transform = transforms.Compose([
    transforms.Resize((440, 440)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

# Predict single image
image = Image.open('anime_frame.jpg').convert('RGB')
x = transform(image).unsqueeze(0)

with torch.no_grad():
    logits = model(x)
    probs = torch.softmax(logits, dim=1)
    pred_idx = logits.argmax(-1).item()
    confidence = probs[0, pred_idx].item()

classes = ['flat', 'modern', 'retro', 'stylised_painterly', 'stylised_pencil']
print(f'{classes[pred_idx]}: {confidence:.1%}')
# Output: modern: 96.5%

Batch Classification with Confidence

from torch.utils.data import DataLoader
from torchvision.datasets import ImageFolder
import pandas as pd

# Load images from folder
dataset = ImageFolder('anime_frames/', transform=transform)
loader = DataLoader(dataset, batch_size=32)

results = []
with torch.no_grad():
    for images, _ in loader:
        logits = model(images)
        probs = torch.softmax(logits, dim=1)
        preds = logits.argmax(-1)
        confs = probs.gather(1, preds.unsqueeze(1)).squeeze()
        
        for pred, conf in zip(preds, confs):
            results.append({'style': classes[pred], 'confidence': conf.item()})

df = pd.DataFrame(results)
print(df.groupby('style')['confidence'].agg(['count', 'mean', 'min']))

Confidence Thresholding (Optional)

If you want to reject ambiguous classifications:

with torch.no_grad():
    logits = model(x)
    probs = torch.softmax(logits, dim=1)
    pred_idx = logits.argmax(-1).item()
    confidence = probs[0, pred_idx].item()
    
    if confidence < 0.85:
        print('Ambiguous — may want to review manually')
    else:
        print(f'{classes[pred_idx]}: {confidence:.1%} (confident)')

Based on OOD evaluation:

  • ≥ 0.95 confidence: >99% accurate
  • 0.85–0.95 confidence: ~97% accurate
  • < 0.85 confidence: Review recommended, especially for pencil class

Use as Style Embedding Model

Beyond classification, this model produces 1,408-dimensional embeddings by global-average-pooling the final convolutional feature map. They may capture visual drawing characteristics such as line weight, shading technique, color palette, and compositing approach, but can also retain scene-content information.

This enables:

  • Batch style search: Find all frames in a 1.5M screencap corpus with matching visual drawing style
  • Series identification: Cluster frames by series/studio without using metadata
  • Style interpolation: Measure how a show's visual style evolves over seasons
  • Synthetic dataset balance: Find style-similar examples of underrepresented classes

Embedding Usage

import torch
from safetensors.torch import load_file
import timm
from PIL import Image
from torchvision import transforms

# Load model
model = timm.create_model('efficientnet_b2', num_classes=5, pretrained=False)
state_dict = load_file('model.safetensors')
model.load_state_dict(state_dict)
model.eval()

transform = transforms.Compose([
    transforms.Resize((440, 440)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

def get_style_embedding(image_path):
    """Extract a 1,408-dim embedding from the final convolutional features."""
    img = Image.open(image_path).convert('RGB')
    x = transform(img).unsqueeze(0)
    with torch.no_grad():
        features = model.forward_features(x)          # [1, 1408, 14, 14]
        embedding = features.mean(dim=[-2, -1])       # [1, 1408] global avg pool
        embedding = embedding / embedding.norm(dim=1, keepdim=True)  # L2 normalize
    return embedding.squeeze(0).numpy()

# Compare two frames
emb_a = get_style_embedding('frame_a.jpg')
emb_b = get_style_embedding('frame_b.jpg')
similarity = emb_a @ emb_b  # cosine similarity (embeddings are L2-normalized)
print(f'Style similarity: {similarity:.4f}')
# > 0.8  = very similar style (likely same series/studio)
# 0.5-0.8 = same style family (e.g., both modern)
# 0.2-0.5 = different but adjacent styles (e.g., modern vs retro)
# < 0.2  = opposite ends of spectrum (e.g., flat vs modern)

Interpreting Embedding Distances

Cosine SimilarityInterpretation
> 0.8Near-identical style (same series, same studio, same season)
0.5 – 0.8Same style family (e.g., two modern AAA shows, or two retro productions)
0.2 – 0.5Different style families but compatible (e.g., modern + painterly)
< 0.2Opposite ends of style spectrum (e.g., flat vs...

Sources

1 source
Hugging FacePrimaryVersion 97466fa0f214e30004ff88282c6bf123d796a0c7
huggingface.co/Mitchins/anime-style-classifier-v6/tree/97466fa0f214e30004ff88282c6bf123d796a0c7

Verified Oct 10

Model artifacts

1 artifact

model.safetensors

safetensors · 29.7 MB · SHA-256 fa85f9e0238c…4cd9 · Hugging Face

Download file

Source excerpts

3 excerpts

--- license: mit tags: - image-classification - anime - art-style - pytorch - efficientnet pipeline_tag: image-classification library_name: timm model_name: anime-style-classifier-v6 base_model: efficientnet_b2 datasets: - custom metrics: - accuracy model-index: - name: anime-style-classifier-v6 results: - task: type: image-classification metrics: - type: accuracy value: 0.9630 name: OOD Accuracy (459 images) language: - ja --- # Anime Style Classifier v6 An EfficientNet-B2 model that classifies anime frames into **5 production style categories**, expanding on v5 by splitting the painterly class into distinct pencil-sketch and painterly substyles. It can also produce **1,408-dimensional pooled feature embeddings** for measuring visual similarity between frames. These embeddings are useful for style-oriented search, but are not guaranteed to be independent of image content. ## Model Details **Architecture** EfficientNet-B2 (timm) **Parameters** 7.7M **Input** 440 × 440 RGB **Embedding dim** 1,408 (global-average-pooled final feature map) **Classes** 5 (`flat`, `modern`, `retro`, `stylised_painterly`, `stylised_pencil`) **Format** SafeTensors **File size** 30 MB **Training data** 97,444 images across 5 classes **Training method** Supervised ASL (Asymmetric Softmax) with batch-balanced sampling ## Classes Style | Description | Example Series ---|---|--- **flat** | Minimal shading, solid color blocks, low gradients | _Ping Pong The Animation_, _Kaiba_, _The Heike Story_ **modern** | High-detail digital pipeline, clean gradients, AAA production | _Demon Slayer_, _Violet Evergarden_, _Attack on Titan_ **retro** | Cel-era aesthetic, grain, limited dynamic range | _Cowboy Bebop_, _Neon Genesis Evangelion_, _Robotech_ **stylised_painterly** | Watercolor/oil feel, visible brush texture, organic transitions | _Mushi-Shi_, _Your Lie in April_, _Land of the Lustrous_ **stylised_pencil** | Sketch/pencil line art, loose strokes, minimalist shading | _Kill la Kill_, _Carole & Tuesday_, _Penguindrum_ ### Style Examples **flat** | **modern** ---|--- ![](./images/example_flat_0.jpg) | ![](./images/example_modern_0.jpg) ![](./images/example_flat_1.jpg) | ![](./images/example_modern_1.jpg) **retro** | **stylised_painterly** ---|--- ![](./images/example_retro_0.jpg) | ![](./images/example_stylised_painterly_0.jpg) ![](./images/example_...

Source context: 65 downloads · 1 likes · Pipeline image-classification · Library timm · Repo Mitchins/anime-style-classifier-v6

Source context: 13 downloads · 0 likes · Pipeline image-classification · Library timm · Repo Mitchins/anime-style-classifier-v6