Upload folder using huggingface_hub
Browse files- README.md +89 -0
- config.json +10 -0
- labels.txt +3 -0
- model.safetensors +3 -0
- model_card.md +145 -0
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Anime/Real/Rendered Image Classifier (EfficientNet-B0)
|
| 2 |
+
|
| 3 |
+
**Fast, lightweight classifier for distinguishing photographs from anime and 3D rendered images.**
|
| 4 |
+
|
| 5 |
+
## Model Details
|
| 6 |
+
|
| 7 |
+
- **Architecture:** EfficientNet-B0 (timm)
|
| 8 |
+
- **Input Size:** 224×224 RGB
|
| 9 |
+
- **Classes:** anime, real, rendered
|
| 10 |
+
- **Parameters:** 5.3M
|
| 11 |
+
- **Validation Accuracy:** 97.44%
|
| 12 |
+
- **Training Speed:** ~1 min/epoch (GPU)
|
| 13 |
+
- **Inference Speed:** ~20ms per image (RTX 3060)
|
| 14 |
+
|
| 15 |
+
## Performance
|
| 16 |
+
|
| 17 |
+
| Class | Precision | Recall | F1-Score |
|
| 18 |
+
|-------|-----------|--------|----------|
|
| 19 |
+
| anime | 0.98 | 0.99 | 0.99 |
|
| 20 |
+
| real | 0.98 | 0.98 | 0.98 |
|
| 21 |
+
| rendered | 0.96 | 0.93 | 0.94 |
|
| 22 |
+
| **macro avg** | **0.97** | **0.97** | **0.97** |
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from PIL import Image
|
| 28 |
+
import torch
|
| 29 |
+
from torchvision import transforms
|
| 30 |
+
import timm
|
| 31 |
+
from safetensors.torch import load_file
|
| 32 |
+
|
| 33 |
+
# Load model
|
| 34 |
+
model = timm.create_model('efficientnet_b0', num_classes=3, pretrained=False)
|
| 35 |
+
state_dict = load_file('model.safetensors')
|
| 36 |
+
model.load_state_dict(state_dict)
|
| 37 |
+
model.eval()
|
| 38 |
+
|
| 39 |
+
# Prepare image
|
| 40 |
+
transform = transforms.Compose([
|
| 41 |
+
transforms.Resize((224, 224)),
|
| 42 |
+
transforms.ToTensor(),
|
| 43 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
| 44 |
+
])
|
| 45 |
+
|
| 46 |
+
image = Image.open('image.jpg').convert('RGB')
|
| 47 |
+
x = transform(image).unsqueeze(0)
|
| 48 |
+
|
| 49 |
+
# Predict
|
| 50 |
+
with torch.no_grad():
|
| 51 |
+
logits = model(x)
|
| 52 |
+
probs = torch.softmax(logits, dim=1)
|
| 53 |
+
pred_class = probs.argmax(dim=1).item()
|
| 54 |
+
|
| 55 |
+
labels = ['anime', 'real', 'rendered']
|
| 56 |
+
print(f"{labels[pred_class]}: {probs[0, pred_class]:.2%}")
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Dataset
|
| 60 |
+
|
| 61 |
+
- **Real:** 5,000 COCO 2017 validation images (diverse real-world scenarios)
|
| 62 |
+
- **Anime:** 2,357 curated anime/animation frames
|
| 63 |
+
- **Rendered:** 1,610 AAA game screenshots + 61 Pixar movie stills
|
| 64 |
+
- **Total:** 8,967 images (8,070 train / 897 val)
|
| 65 |
+
|
| 66 |
+
## Training Details
|
| 67 |
+
|
| 68 |
+
- **Augmentation:** Raw (resize only)
|
| 69 |
+
- **Optimizer:** AdamW (lr=0.001)
|
| 70 |
+
- **Loss:** CrossEntropyLoss with class weighting
|
| 71 |
+
- **Epochs:** 20
|
| 72 |
+
- **Batch Size:** 80
|
| 73 |
+
- **Hardware:** NVIDIA RTX 3060 (12GB)
|
| 74 |
+
|
| 75 |
+
## Known Limitations
|
| 76 |
+
|
| 77 |
+
- **Real vs Rendered:** Some confusion (photorealistic games misclassified as real)
|
| 78 |
+
- **Stylized Games:** Cel-shaded games (e.g., Fate/Extella) may score as anime
|
| 79 |
+
- **Pixar:** Stylized rendered images may show mixed confidence
|
| 80 |
+
|
| 81 |
+
## Recommendations
|
| 82 |
+
|
| 83 |
+
- Use ensemble with tf_efficientnetv2_s for critical applications
|
| 84 |
+
- Apply confidence threshold: only trust predictions >85% confidence
|
| 85 |
+
- For edge cases, use the full confusion matrix to understand failure modes
|
| 86 |
+
|
| 87 |
+
## License
|
| 88 |
+
|
| 89 |
+
This model is provided as-is for research and educational purposes.
|
config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "efficientnet_b0",
|
| 3 |
+
"num_classes": 3,
|
| 4 |
+
"input_size": 224,
|
| 5 |
+
"labels": [
|
| 6 |
+
"anime",
|
| 7 |
+
"real",
|
| 8 |
+
"rendered"
|
| 9 |
+
]
|
| 10 |
+
}
|
labels.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
0: anime
|
| 2 |
+
1: real
|
| 3 |
+
2: rendered
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @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|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: openrail
|
| 3 |
+
language: en
|
| 4 |
+
library_name: timm
|
| 5 |
+
tags:
|
| 6 |
+
- image-classification
|
| 7 |
+
- anime
|
| 8 |
+
- real
|
| 9 |
+
- rendered
|
| 10 |
+
- 3d-graphics
|
| 11 |
+
datasets:
|
| 12 |
+
- coco
|
| 13 |
+
- custom-anime
|
| 14 |
+
- steam-screenshots
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# EfficientNet-B0 - Anime/Real/Rendered Classifier
|
| 18 |
+
|
| 19 |
+
Fast, lightweight image classifier distinguishing photographs from anime and 3D rendered images.
|
| 20 |
+
|
| 21 |
+
## Model Summary
|
| 22 |
+
|
| 23 |
+
- **Model Name:** efficientnet_b0
|
| 24 |
+
- **Framework:** PyTorch + TIMM
|
| 25 |
+
- **Input:** 224×224 RGB images
|
| 26 |
+
- **Output:** 3 classes (anime, real, rendered)
|
| 27 |
+
- **Parameters:** 5.3M
|
| 28 |
+
- **Size:** 16.2 MB
|
| 29 |
+
|
| 30 |
+
## Intended Use
|
| 31 |
+
|
| 32 |
+
Classify images into three categories:
|
| 33 |
+
- **anime**: Drawn 2D or cel-shaded animation
|
| 34 |
+
- **real**: Photographs and real-world footage
|
| 35 |
+
- **rendered**: 3D graphics (games, CGI, Pixar, etc.)
|
| 36 |
+
|
| 37 |
+
## Performance
|
| 38 |
+
|
| 39 |
+
**Validation Accuracy:** 97.44%
|
| 40 |
+
|
| 41 |
+
| Class | Precision | Recall | F1-Score | Support |
|
| 42 |
+
|-------|-----------|--------|----------|---------|
|
| 43 |
+
| anime | 0.98 | 0.99 | 0.99 | 236 |
|
| 44 |
+
| real | 0.98 | 0.98 | 0.98 | 500 |
|
| 45 |
+
| rendered | 0.96 | 0.93 | 0.94 | 161 |
|
| 46 |
+
| **weighted avg** | **0.97** | **0.97** | **0.97** | **897** |
|
| 47 |
+
|
| 48 |
+
## Training Data
|
| 49 |
+
|
| 50 |
+
- **Real images:** 5,000 COCO 2017 validation set images
|
| 51 |
+
- **Anime images:** 2,357 curated animation frames and key scenes
|
| 52 |
+
- **Rendered images:** 1,549 AAA game screenshots (Metacritic ≥75) + 61 Pixar movie stills
|
| 53 |
+
- **Total:** 8,967 images, 8,070 training, 897 validation (perceptually-hashed for diversity)
|
| 54 |
+
|
| 55 |
+
## Training Details
|
| 56 |
+
|
| 57 |
+
- **Framework:** PyTorch
|
| 58 |
+
- **Augmentation:** Resize only (224×224)
|
| 59 |
+
- **Loss Function:** CrossEntropyLoss with inverse frequency class weights
|
| 60 |
+
- **Optimizer:** AdamW (lr=0.001)
|
| 61 |
+
- **Batch Size:** 80
|
| 62 |
+
- **Epochs:** 20
|
| 63 |
+
- **Hardware:** NVIDIA RTX 3060 (12GB VRAM)
|
| 64 |
+
- **Training Time:** ~20 minutes
|
| 65 |
+
|
| 66 |
+
## Limitations
|
| 67 |
+
|
| 68 |
+
1. Photorealistic video games sometimes classified as real (90% recall on rendered class)
|
| 69 |
+
2. Cel-shaded games may score as anime rather than rendered
|
| 70 |
+
3. Artistic 3D renders (Pixar, high-quality CGI) show mixed confidence
|
| 71 |
+
4. Performance degrades on images <224×224
|
| 72 |
+
|
| 73 |
+
## Recommendations
|
| 74 |
+
|
| 75 |
+
- Use confidence threshold of ≥80% for reliable predictions
|
| 76 |
+
- For critical applications, ensemble with tf_efficientnetv2_s
|
| 77 |
+
- Check confusion patterns in own use cases
|
| 78 |
+
- Manually review edge cases (game screenshots, stylized renders)
|
| 79 |
+
|
| 80 |
+
## How to Use
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
from PIL import Image
|
| 84 |
+
import torch
|
| 85 |
+
from torchvision import transforms
|
| 86 |
+
import timm
|
| 87 |
+
from safetensors.torch import load_file
|
| 88 |
+
|
| 89 |
+
# Load
|
| 90 |
+
model = timm.create_model('efficientnet_b0', num_classes=3, pretrained=False)
|
| 91 |
+
state_dict = load_file('model.safetensors')
|
| 92 |
+
model.load_state_dict(state_dict)
|
| 93 |
+
model.eval()
|
| 94 |
+
|
| 95 |
+
# Prepare image
|
| 96 |
+
transform = transforms.Compose([
|
| 97 |
+
transforms.Resize((224, 224)),
|
| 98 |
+
transforms.ToTensor(),
|
| 99 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
| 100 |
+
])
|
| 101 |
+
img = Image.open('image.jpg').convert('RGB')
|
| 102 |
+
x = transform(img).unsqueeze(0)
|
| 103 |
+
|
| 104 |
+
# Infer
|
| 105 |
+
with torch.no_grad():
|
| 106 |
+
logits = model(x)
|
| 107 |
+
probs = torch.softmax(logits, dim=1)
|
| 108 |
+
pred = probs.argmax().item()
|
| 109 |
+
|
| 110 |
+
labels = ['anime', 'real', 'rendered']
|
| 111 |
+
print(f"{labels[pred]}: {probs[0, pred]:.1%}")
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
## Benchmarks
|
| 115 |
+
|
| 116 |
+
**Inference Speed (RTX 3060)**
|
| 117 |
+
- Single image: ~20ms
|
| 118 |
+
- Batch of 32: ~150ms
|
| 119 |
+
|
| 120 |
+
**Accuracy Comparison**
|
| 121 |
+
| Model | Accuracy | Speed | Params |
|
| 122 |
+
|-------|----------|-------|--------|
|
| 123 |
+
| EfficientNet-B0 | 97.44% | Fast | 5.3M |
|
| 124 |
+
| TF-EfficientNetV2-S | 97.55% | Moderate | 21.5M |
|
| 125 |
+
|
| 126 |
+
## Ethical Considerations
|
| 127 |
+
|
| 128 |
+
This model classifies images by visual style/source. Potential misuse:
|
| 129 |
+
- Detecting deepfakes/AI-generated content (not designed for this)
|
| 130 |
+
- Filtering user-generated content (may have cultural bias)
|
| 131 |
+
- Surveillance or profiling
|
| 132 |
+
|
| 133 |
+
**Recommendations:**
|
| 134 |
+
- Use with human review for content moderation
|
| 135 |
+
- Test on your target domain before deployment
|
| 136 |
+
- Don't rely solely on automatic classification for safety-critical decisions
|
| 137 |
+
- Consider cultural representation in anime/rendered content
|
| 138 |
+
|
| 139 |
+
## Contact
|
| 140 |
+
|
| 141 |
+
For questions or issues: [GitHub repo]
|
| 142 |
+
|
| 143 |
+
## License
|
| 144 |
+
|
| 145 |
+
OpenRAIL (Open Responsible AI License) - free for research and commercial use with proper attribution
|