File size: 2,446 Bytes
c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e 650eba7 e3dc99e 650eba7 e3dc99e 650eba7 e3dc99e 650eba7 e3dc99e c4ab7df e3dc99e 650eba7 e3dc99e 650eba7 e3dc99e 650eba7 c4ab7df e3dc99e c4ab7df e3dc99e c4ab7df e3dc99e 650eba7 e3dc99e 650eba7 e3dc99e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# Pokémon Image Classification Model 🎮✨
This repository contains a deep learning-based Pokémon classification model trained on a diverse dataset of Pokémon images. The model leverages **ResNet101** and is fine-tuned to identify Pokémon based on their images.
---
## Features 🐾
- **High Accuracy**: Achieves a **test accuracy of 91.35%**! 🎉
- **Supports 208 Pokémon classes**! 🛡️🗡️
---
## Performance Metrics 📊
### Final Results:
- **Test Accuracy**: `91.35%`
- **Validation Accuracy**: `86.89%`
- **Training Accuracy**: `99.89%`
### Confusion Matrix Visualization 🎯

This confusion matrix gives a detailed view of the classification performance for each Pokémon class. Misclassifications are represented along the off-diagonal cells.
---
## Dataset 📂
- **Source**: Pokémon images dataset curated from various resources.
- **Structure**:
- `images/`: Contains all Pokémon images.
- `pokemon.csv`: Metadata linking each image to its respective Pokémon and class labels.
---
## Model Details 🧠
- **Architecture**: Fine-tuned **ResNet101**.
- **Optimizer**: Adam with learning rate scheduling.
- **Loss Function**: Cross-Entropy Loss.
---
## Usage 🚀
### Loading the Model
```python
import torch
from torchvision import models
import pickle
# Load the model
model = models.resnet101()
num_features = model.fc.in_features
model.fc = torch.nn.Linear(num_features, 208) # Update for Pokémon classes
model.load_state_dict(torch.load('pokemon_model_best.pth'))
model.eval()
# Load label mapping
with open('label_mapping.pkl', 'rb') as f:
label_mapping = pickle.load(f)
```
### Making Predictions
```python
from PIL import Image
from torchvision import transforms
# Define transforms
val_transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
# Load image
image = Image.open('path/to/image.png').convert('RGB')
input_tensor = val_transform(image).unsqueeze(0)
# Predict
with torch.no_grad():
output = model(input_tensor)
_, predicted_class = torch.max(output, 1)
# Map prediction to label
idx_to_name = {v: k for k, v in label_mapping.items()}
predicted_name = idx_to_name[predicted_class.item()]
print(f"Predicted Pokémon: {predicted_name}")
```
---
Feel free to explore and use the model. Contributions are welcome! 🙌
|