A REST API built with FastAPI that uses a Vision Transformer (ViT) model (skshmjn/Pokemon-classifier-gen9-1025) to classify Pokémon from uploaded images and retrieve enriched metadata via PokéAPI.
- FastAPI: High-performance, modern web framework.
- Vertex AI: Use Google Cloud Vertex AI for high-accuracy Pokémon classification.
- Vision Transformer: Fine-tuned ViT for high-accuracy Pokémon classification as backup.
- Full Gen 9 Support: Recognizes all 1,025 Pokémon.
- Dynamic Metadata: Enriches results with real-time data from PokéAPI (types, description, region, etc.).
- 3DS Compatibility:
- Supports raw 3DS framebuffer uploads (BGR565).
- Provides a
/spriteendpoint that returns 3DS-native 8x8 tiled RGBA8888 sprites.
-
Clone or navigate to the project:
cd pokemon-classifier-api -
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment: Create a
.envfile in the root directory:POKEMON_API_KEY=your_secret_api_key MODEL_NAME=skshmjn/Pokemon-classifier-gen9-1025
Start the server using uvicorn:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload- Health Check:
GET http://localhost:8000/(RequiresX-API-KEY) - Swagger Documentation:
http://localhost:8000/docs
The API uses header-based authentication for all endpoints.
- Header:
X-API-KEY - Value: The key defined in your
.envfile (defaults toCHANGEME_PLEASEif not set).
POST /classify
Standard multipart/form-data upload:
curl -X POST "http://localhost:8000/classify" \
-H "X-API-KEY: your_secret_api_key" \
-H "Content-Type: multipart/form-data" \
-F "file=@/path/to/your/pokemon_image.png"Nintendo 3DS Support:
If the User-Agent contains "3DS", the API accepts a raw 400x240 BGR565 framebuffer (192,000 bytes) and automatically rotates it 90 degrees for processing.
GET /pokemon/{name}
curl -X GET "http://localhost:8000/pokemon/pikachu" \
-H "X-API-KEY: your_secret_api_key"GET /pokemon/{name}/sprite
Returns an 8x8 tiled RGBA8888 byte stream, ready for the 3DS GPU (PICA200).
curl -X GET "http://localhost:8000/pokemon/pikachu/sprite?size=64" \
-H "X-API-KEY: your_secret_api_key" \
--output pikachu.bin- Pre-download Model: Cache the Hugging Face model locally before starting the server.
python scripts/download_model.py
Metadata is fetched dynamically via the pokebase library, which interacts with the PokéAPI. Names are loaded at startup, and full details are retrieved and cached on demand.
The API will call Vertex AI in Google Cloud to identify Pokemon (I got lazy to train a model for Pokemon Fossil Museum. I had looked into Label Studio, but it looked like a lot of work to train the model and ML backends were a nightmare to try to set up). If unreachable, the API uses a fine-tuned Vision Transformer (ViT) model.
08/15/2026 - API identitied 60% of Pokemon at field museum. People were sorta impressed. API will probably be discontinued.