Pokedex Project
Collection
This collection includes a model, dataset, and demo space designed to recognize and classify first-generation Pokémon.
•
3 items
•
Updated
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}%")
Input reqs: 224×224×3 RGB, normalized.
Downstream deps: Class index→Pokémon metadata lookup.
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)
Collected via scripts from public archives.
Pre-processing: resize to 224×224, normalize.
Test accuracy: 96%
Only original 151.
Fails on non-canonical art styles, low light, occlusion.
Explore the model training and inference workflow in this interactive notebook:
Visit the live Space to try it out:
Base model
keras/densenet_201_imagenet