|
Download README.md from meryembarkallah21/Poke: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/meryembarkallah21/Poke/resolve/main/README.md
- Command line
-
hf download hf://meryembarkallah21/Poke/README.md
-
curl -L -o README.md https://huggingface.co/meryembarkallah21/Poke/resolve/main/README.md
2.45 kB
| # 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! 🙌 | |