---
license: mit
language:
- en
metrics:
- accuracy
pipeline_tag: image-classification
tags:
- TensorFlow
- Keras
- Pokedex
- Image-Classification
datasets:
- RogerKoala/gen1-pokemon-images
base_model:
- keras/densenet_201_imagenet
library_name: keras
---
[](#google-colab-notebook)
| [](#demo)
# Model Summary
* Architecture: DenseNet121.
* Accuracy: 96% on the test set.
* Framework: Tensorflow.
## Usage
```
import keras
from keras.src.utils import load_img
from keras.src.applications.densenet import preprocess_input
import numpy as np
pokedex = keras.saving.load_model("pokedex.keras")
image = load_img('image.png', target_size=(224, 224))
x = keras.utils.img_to_array(image)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = pokedex.predict(x)
# Important: You must ensure that the Pokémon are ordered alphabetically, as the model was trained using this sequence. You can obtain the .txt file from the following link: https://huggingface.co/spaces/RogerKoala/Pokedex/blob/main/Pokemons.txt
with open('Pokemons.txt', 'r') as f:
class_labels = f.read().splitlines()
top_indices = preds[0].argsort()[-3:][::-1]
for i in top_indices:
print(f"{class_labels[i]}: {preds[0][i]*100:.2f}%")
```
## System
- Input reqs: 224×224×3 RGB, normalized.
- Downstream deps: Class index→Pokémon metadata lookup.
## Implementation requirements
- Training: T4 Google Colab.
- Duration: 1 hour and 15 minutes.
# Model Characteristics
## Model initialization
- Fine-tuned from ImageNet DenseNet121.
## Model stats
| Layer (type) | Output Shape | Param # |
|------------------------------|----------------------|-------------|
| densenet121 (Functional) | (None, 7, 7, 1024) | 7,037,504 |
| global_average_pooling2d (GlobalAveragePooling2D) | (None, 1024) | 0 |
| dense (Dense) | (None, 128) | 131,200 |
| dropout (Dropout) | (None, 128) | 0 |
| dense_1 (Dense) | (None, 151) | 19,479 |
**Total params:** 21,397,255 (81.62 MB)
**Trainable params:** 7,104,535 (27.10 MB)
**Non-trainable params:** 83,648 (326.75 KB)
**Optimizer params:** 14,209,072 (54.20 MB)
## Training data
- Collected via scripts from public archives.
- Pre-processing: resize to 224×224, normalize.
## Evaluation data
- Train: 2249 images.
- Test: 840 images.
# Evaluation Results
## Summary
Test accuracy: 96%
## Usage limitations
- Only original 151.
- Fails on non-canonical art styles, low light, occlusion.
## Google Colab Notebook
Explore the model training and inference workflow in this interactive notebook:
* [Pokédex Colab Notebook](https://colab.research.google.com/drive/1IeGzndeOZ_9PnnWSnLjYgaS7QFn-4Voc?usp=sharing)
## Demo
Visit the live Space to try it out:
* [Hugging Face Space](https://huggingface.co/spaces/RogerKoala/Pokedex)