Downloads · 30 days
4
5% of all-time downloads
Mitchins/anime-frame-interesting-classifier-vit-v2
anime-frame-interesting-classifier-vit-v2 is a machine learning model from Mitchins. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Architecture: MobileViT-Small (Transformer) Framework: Hugging Face Transformers Input Size: 224x224 RGB images Output: Binary classification (Boring/Interesting)
Downloads · 30 days
4
5% of all-time downloads
All-time downloads
83
Public
Parameters
5M
19.9 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors19.9 MB · 100%
From the Hugging Face model README
Architecture: MobileViT-Small (Transformer)
Framework: Hugging Face Transformers
Input Size: 224x224 RGB images
Output: Binary classification (Boring/Interesting)
Evaluated on v2.0 test set (433 frames):
Training data: 3,999 frames (4,432 total with test holdout)
What it does: Classifies anime frames as either "interesting" (depicting meaningful character/scene details) or "boring" (back-of-head shots, non-descript backgrounds, montages).
Strengths:
When to use:
When NOT to use:
All frames are 224x224 RGB anime screenshots.
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
# Load model (automatically uses SafeTensors)
processor = AutoImageProcessor.from_pretrained(
'hf_models/anime-frame-interesting-classifier-vit-v2'
)
model = AutoModelForImageClassification.from_pretrained(
'hf_models/anime-frame-interesting-classifier-vit-v2',
trust_remote_code=False # Safe: SafeTensors prevents code execution
)
model.eval()
image = Image.open('frame.png')
inputs = processor(image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = logits.argmax(-1).item()
confidence = logits.softmax(-1)[0][prediction].item()
print(f"Prediction: {'Interesting' if prediction == 1 else 'Boring'}")
print(f"Confidence: {confidence:.2%}")
from transformers import MobileViTForImageClassification, AutoImageProcessor
from safetensors.torch import load_file
from PIL import Image
import torch
# Load with SafeTensors (secure)
model = MobileViTForImageClassification.from_pretrained(
'apple/mobilevit-small',
num_labels=2
)
state_dict = load_file('model.safetensors')
model.load_state_dict(state_dict)
model.eval()
processor = AutoImageProcessor.from_pretrained('apple/mobilevit-small')
image = Image.open('frame.png')
inputs = processor(image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
prediction = outputs.logits.argmax(-1).item()
print(f"Prediction: {'Interesting' if prediction == 1 else 'Boring'}")
Security Note: This model uses SafeTensors format (not pickle). SafeTensors is a secure serialization format that cannot execute arbitrary code during loading, unlike pickle-based .bin files.
See anime-frame-interesting-classifier-cnn-v2 for CNN alternative:
| Metric | ViT (This Model) | CNN | Use Case |
|---|---|---|---|
| F1 | 94.92% | 95.15% | ViT: ensemble, CNN: general |
| Speed | Slower | Faster | CNN preferred for speed |
| Size | 20 MB | 20 MB | Similar footprint |
| Semantics | Better understanding | Good efficiency | ViT for understanding |
| Ensemble | Better recall with CNN voting | Better precision with ViT voting | Use together |
Recommended: Use ensemble voting for maximum confidence:
If you use this model, please reference:
For best results, use both CNN and ViT models together:
def ensemble_classify(image_path, cnn_model, vit_model):
"""Classify with both models, flag disagreements"""
# CNN prediction
cnn_pred = classify_with_cnn(image_path, cnn_model)
# ViT prediction
vit_pred = classify_with_vit(image_path, vit_model)
if cnn_pred['class'] == vit_pred['class']:
# Agreement: high confidence
confidence = (cnn_pred['conf'] + vit_pred['conf']) / 2
return {
'prediction': cnn_pred['class'],
'confidence': confidence,
'agreement': 'both'
}
else:
# Disagreement: flag for manual review
return {
'cnn': cnn_pred,
'vit': vit_pred,
'agreement': 'none',
'recommendation': 'manual_review'
}