Fullname commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
base_model:
|
|
|
|
| 1 |
+
# Pokemon Team Classification with Vision Transformer
|
| 2 |
+
|
| 3 |
+
A fine-tuned Vision Transformer (ViT) model for classifying 6 specific Pokemon from a competitive team setup. This model can identify Arceus, Marshadow, Sandy Shocks, Slaking, Reshiram, and Magearna with high accuracy.
|
| 4 |
+
|
| 5 |
+
## Model Details
|
| 6 |
+
|
| 7 |
+
- **Base Model**: `google/vit-base-patch16-224`
|
| 8 |
+
- **Model Type**: Vision Transformer for Image Classification
|
| 9 |
+
- **Classes**: 6 Pokemon (Arceus, Marshadow, Sandy Shocks, Slaking, Reshiram, Magearna)
|
| 10 |
+
- **Input Size**: 224x224 RGB images
|
| 11 |
+
- **Framework**: PyTorch + Transformers
|
| 12 |
+
|
| 13 |
+
## Training Details
|
| 14 |
+
|
| 15 |
+
### Dataset
|
| 16 |
+
- **Arceus**: 644 images
|
| 17 |
+
- **Marshadow**: 101 images
|
| 18 |
+
- **Sandy Shocks**: 75 images
|
| 19 |
+
- **Slaking**: 152 images
|
| 20 |
+
- **Reshiram**: 118 images
|
| 21 |
+
- **Magearna**: 200 images
|
| 22 |
+
|
| 23 |
+
### Training Strategy
|
| 24 |
+
- **Balanced Sampling**: Each epoch uses exactly 75 samples per class to prevent overfitting on Arceus
|
| 25 |
+
- **Data Augmentation**: Random horizontal flip, rotation (±15°), color jitter, and resized crop
|
| 26 |
+
- **Transfer Learning**: Froze early ViT layers, fine-tuned classifier and later transformer layers
|
| 27 |
+
- **Early Stopping**: Training stopped when validation loss plateaued (patience=3 epochs)
|
| 28 |
+
|
| 29 |
+
### Hyperparameters
|
| 30 |
+
- **Learning Rate**: 2e-5
|
| 31 |
+
- **Batch Size**: 16
|
| 32 |
+
- **Weight Decay**: 0.01
|
| 33 |
+
- **Optimizer**: AdamW
|
| 34 |
+
- **Epochs**: ~18 (early stopped from max 1000)
|
| 35 |
+
|
| 36 |
+
## Performance
|
| 37 |
+
|
| 38 |
+
The model achieves excellent classification performance with balanced accuracy across all 6 Pokemon classes despite the imbalanced training dataset.
|
| 39 |
+
|
| 40 |
+
## Usage
|
| 41 |
+
|
| 42 |
+
### Basic Classification
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from transformers import ViTImageProcessor, ViTForImageClassification
|
| 46 |
+
from PIL import Image
|
| 47 |
+
import torch
|
| 48 |
+
|
| 49 |
+
# Load model and processor
|
| 50 |
+
model = ViTForImageClassification.from_pretrained("your-username/pokemon-team-vit")
|
| 51 |
+
processor = ViTImageProcessor.from_pretrained("your-username/pokemon-team-vit")
|
| 52 |
+
|
| 53 |
+
# Load and process image
|
| 54 |
+
image = Image.open("pokemon_image.jpg")
|
| 55 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 56 |
+
|
| 57 |
+
# Get predictions
|
| 58 |
+
with torch.no_grad():
|
| 59 |
+
outputs = model(**inputs)
|
| 60 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 61 |
+
|
| 62 |
+
# Get results
|
| 63 |
+
pokemon_names = ["arceus", "marshadow", "sandy-shocks", "slaking", "reshiram", "magearna"]
|
| 64 |
+
predicted_class = predictions.argmax().item()
|
| 65 |
+
confidence = predictions.max().item()
|
| 66 |
+
|
| 67 |
+
print(f"Predicted: {pokemon_names[predicted_class]} (confidence: {confidence:.2%})")
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### Detailed Probabilities
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
# Get all class probabilities
|
| 74 |
+
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)[0]
|
| 75 |
+
|
| 76 |
+
results = {}
|
| 77 |
+
for idx, pokemon in enumerate(pokemon_names):
|
| 78 |
+
results[pokemon] = float(probabilities[idx])
|
| 79 |
+
|
| 80 |
+
# Sort by probability
|
| 81 |
+
sorted_results = sorted(results.items(), key=lambda x: x[1], reverse=True)
|
| 82 |
+
for pokemon, prob in sorted_results:
|
| 83 |
+
print(f"{pokemon}: {prob:.1%}")
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## Applications
|
| 87 |
+
|
| 88 |
+
- **Pokemon Recognition**: Identify specific Pokemon in images, artwork, or screenshots
|
| 89 |
+
- **Competitive Team Analysis**: Analyze team compositions in competitive Pokemon content
|
| 90 |
+
- **Content Moderation**: Filter or categorize Pokemon-related content
|
| 91 |
+
- **Educational Tools**: Pokemon identification for learning applications
|
| 92 |
+
|
| 93 |
+
## Limitations
|
| 94 |
+
|
| 95 |
+
- **Specific Pokemon Only**: Only recognizes the 6 trained Pokemon classes
|
| 96 |
+
- **Image Quality**: Performance may vary with very low resolution or heavily distorted images
|
| 97 |
+
- **Artistic Variations**: May struggle with highly stylized or non-canonical Pokemon representations
|
| 98 |
+
- **Background Complexity**: Performance may decrease with very cluttered backgrounds
|
| 99 |
+
|
| 100 |
+
## Model Architecture
|
| 101 |
+
|
| 102 |
+
The model uses the Vision Transformer (ViT) architecture:
|
| 103 |
+
- **Patch Size**: 16x16
|
| 104 |
+
- **Hidden Size**: 768
|
| 105 |
+
- **Attention Heads**: 12
|
| 106 |
+
- **Layers**: 12
|
| 107 |
+
- **Parameters**: ~86M (base model) + classification head
|
| 108 |
+
|
| 109 |
+
## Training Infrastructure
|
| 110 |
+
|
| 111 |
+
- **Hardware**: AMD GPU with ROCm support
|
| 112 |
+
- **Framework**: PyTorch with Transformers library
|
| 113 |
+
- **Duration**: ~2 minutes per epoch, early stopped at epoch 18
|
| 114 |
+
- **Memory**: Optimized for consumer-grade GPU memory
|
| 115 |
+
|
| 116 |
+
## Citation
|
| 117 |
+
|
| 118 |
+
If you use this model, please cite:
|
| 119 |
+
|
| 120 |
+
```bibtex
|
| 121 |
+
@misc{pokemon-team-vit,
|
| 122 |
+
title={Pokemon Team Classification with Vision Transformer},
|
| 123 |
+
author={Steven Van Ingelgem},
|
| 124 |
+
year={2025},
|
| 125 |
+
url={https://huggingface.co/your-username/pokemon-team-vit}
|
| 126 |
+
}
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
## License
|
| 130 |
+
|
| 131 |
+
This model is released under the MIT License. The training data consists of Pokemon images which are © The Pokémon Company/Nintendo. This model is for research and educational purposes.
|
| 132 |
+
|
| 133 |
+
## Acknowledgments
|
| 134 |
+
|
| 135 |
+
- Base model: Google's Vision Transformer (ViT)
|
| 136 |
+
- Training framework: Hugging Face Transformers
|
| 137 |
+
- Pokemon images: Various sources for competitive team analysis
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
**Note**: This model is specifically trained for a competitive Pokemon team setup and may not generalize to other Pokemon or use cases. For broader Pokemon classification, consider training on a more comprehensive dataset.
|
| 142 |
+
|
| 143 |
+
|
| 144 |
---
|
| 145 |
license: mit
|
| 146 |
base_model:
|