Pokémon Image Classification 🐾
Collection
This collection includes a dataset and a trained ResNet-101 model for Pokémon image classification. The dataset contains annotated Pokémon ima • 3 items • Updated • 2
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
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.
91.35%86.89%99.89%This confusion matrix gives a detailed view of the classification performance for each Pokémon class. Misclassifications are represented along the off-diagonal cells.
images/: Contains all Pokémon images.pokemon.csv: Metadata linking each image to its respective Pokémon and class labels.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)
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! 🙌