Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Pokemon GPT-2

This repo contains EVERYTHING you need to train a GPT-2 model with images of your choosing THEN generate new images with that model.

Google Colab Notebooks

There's a good chance you can do what you want directly with Google Colab (and use a shiny free GPU):


For those of you (sickos!) that want to run this code locally, here is a rundown of the key files:

  • - Converts images into a text-based format for training.
  • - Converts text-based image format into a PNG.
  • - Trains a GPT-2 model with input text.
  • - Generates images with a trained model.
  • misc/ - This folder contains things that are probably not useful but were used in this project. USE AT YOUR OWN PERIL !
    • image-to-text.js - The original Javascript implementation of image-to-text (outofdate!)
    • remove-background.js - Removes white surrounding an image and replaces with transparent pixels.
    • resize.js - Centers images into a certain size. I don't remember why I didn't just use imagemagick, but I must have had a good reason.
    • text-to-image.js - The original Javascript implementation of text-to-image (outofdate!)


So you want to do the thing ? You don't just want to use the Google Colab Notebook ? Weird, but okay try this:

  1. Install the requirements. People like to do that like this: pip install -r requirements.txt
  2. Get your input images into a folder. I used a bunch of Pokemon sprites all sized to 64x64.
  3. Convert those images into a big text file like this: python images/*.png > all-image.txt
  4. Modify (i trust you) to your liking. Good stuff start at line 8. More steps = more training.
  5. Run and wait a long time !
  6. Make a folder named "output". (yeah yeah)
  7. Now modify to your needs. Line 6-9 and line 27. Temp in line 35 controls "craziness" of output.
  8. Run and wait a long time !
  9. Turn the output texts into images with: python output/*.txt
  10. Enjoy your sprites in output folder !
  11. Tweak input, settings, etc. and repeat !

Pre-Trained Model

If you want to generate sprites with a model already trained on Pokemon sprites you can download my model here:

To use this, make a folder named "checkpoint" and place the unzipped pokemon-gpt-2-multigen-250000 folder there then follow above instructions from step 8 on.

Thanks !

Big thanks to the GPT-2-Simple project by Max Woolf. I wouldn't have done any of this if that project hadn't made GPT-2 work so straight forward.


No description, website, or topics provided.






No releases published


No packages published