Skip to content

jnolis/banned-license-plates

Repository files navigation

Banned license plates generator

Offensive license plates

Deploy

Edit and run this code online in RStudio for free using Saturn Cloud

This R code uses Keras to train a neural network on license plates that were banned by the Arizona Department of Transportation. It was my attempt at using neural networks to make something funny like the AI trained on band names, video game titles, and pokemon.

The code is based heavily on the RStudio text generation example.

The license plate corpus comes from a google search and is included in the repository, however I have a Public Records Request out for more recent data from the state.

The code is broken into three files:

  1. train_model.R - This script trains a neural network on the license plates.
  2. runtime_functions.R - This script contains functions that let you use the model to generate license plates.
  3. parameters.R - This script contains the parameters needed at both training and runtime. If you change this file at all you'll need to rerun the train_model.R script!

To run the code, first make sure your have keras and tensorflow installed on your computer. You can use the Rstudio guide to do this. Run train_model.R to train a model (or use the one included in the repository). Then run runtime_functions.R to load the completed model, and use those functions to generate names.

Train a model:

source("train_model.R") # (optional) train a new model

Run a model:

source("runtime_functions.R") # load the completed model

# generate a single license plate
generate_result(model, character_lookup, max_length)
# [1] "CH3SXYR"

#generate many license plates
generate_many_results(20, model, character_lookup, max_length)
# [1] "MANTER9" "HITNHUT" "H8NSX"   "COX3XXX" "FUAACHO" "BAMF"    "B1TGUAN" "2DAMLOW" "4STRUT"  "C0MMAMP" "PASFTC"  "H8LTRS" 
# [13] "SUKFTC"  "LEESHOG" "GTONADE" "MRUIC69" "TUZHI"   "LUVBUNK" "TITEIL"  "HO4FIN" 

Next steps

CHANGE LOG:

  • 2021-12-21: Updated for newer TensorFlow and added Saturn Cloud support.
  • 2019-06-08: Fixed some minor issues with the max_length parameter.
  • 2019-05-29: This code was refactored to reflect best practices and be in line with other models, such as the pet names neural network.
  • 2018-12-05: Made the code use the pad_sequences and to_categorical functions from the keras package
  • 2018-02-08: Initial release

About

Using R and Keras to generate banned license plates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages