Skip to content

Instantly share code, notes, and snippets.

@bdunnette
Last active May 27, 2021 17:03
Show Gist options
  • Save bdunnette/69ad08139b09d6a1ef7dfeab16d57500 to your computer and use it in GitHub Desktop.
Save bdunnette/69ad08139b09d6a1ef7dfeab16d57500 to your computer and use it in GitHub Desktop.
derby_names.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "derby_names.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/bdunnette/69ad08139b09d6a1ef7dfeab16d57500/derby_names.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fMO1Y1Qj5LWt"
},
"source": [
"Generating [derby names](https://en.wikipedia.org/wiki/Roller_derby#Derby_names) from publicly-accessible lists\n",
"\n",
"Adapted from Max Woolf's notebook: https://drive.google.com/file/d/1mMKGnVxirJnqDViH7BDJxFqWrsXlPSoK/view?usp=sharing\n",
"\n",
"Inspired by Janelle Shane's blog post: http://aiweirdness.com/post/174466734677/neural-network-generated-roller-derby-names"
]
},
{
"cell_type": "code",
"metadata": {
"id": "j5sZ7k49z9FR",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "a7b63278-a66c-4a65-8b2e-7e0e17b3c4cb"
},
"source": [
"%tensorflow_version 2.x\n",
"!pip3 install -q git+git://github.com/minimaxir/textgenrnn.git"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
" Building wheel for textgenrnn (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "JE1DkeW22bug",
"outputId": "f86c54f4-ac99-4286-f20d-690e0bbd9979"
},
"source": [
"import tensorflow as tf\n",
"print('TensorFlow v{0}'.format(tf.__version__))\n",
"device_name = tf.test.gpu_device_name()\n",
"if device_name != '/device:GPU:0':\n",
" print('GPU device not found')\n",
"else:\n",
" print('Found GPU at: {}'.format(device_name))"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"TensorFlow v2.5.0\n",
"Found GPU at: /device:GPU:0\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "zxMLEnyTe7B_"
},
"source": [
"import string\n",
"import random\n",
"from datetime import datetime\n",
"from pathlib import Path\n",
"from zipfile import ZipFile\n",
"\n",
"from google.colab import files\n",
"import keras\n",
"from textgenrnn import textgenrnn\n",
"from bs4 import BeautifulSoup\n",
"import requests\n",
"import pandas as pd\n",
"from sklearn.utils import shuffle"
],
"execution_count": 18,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "7a49OXrue_NW"
},
"source": [
"training_file = Path(\"derby_names.txt\")\n",
"model_name = 'derbynames' "
],
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "51mDvze3U621"
},
"source": [
"session = requests.Session()"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "v0o8T_WdCy7X",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 436
},
"outputId": "adc1a364-844a-4e88-dfac-0cb9350dd515"
},
"source": [
"url = \"https://www.twoevils.org/rollergirls/\"\n",
"print(\"Downloading names from %s\" % url)\n",
"r = session.get(url)\n",
"soup = BeautifulSoup(r.text, \"lxml\")\n",
"rows = soup.find_all('tr', {'class':['trc1', 'trc2']})\n",
"twoevils_names = [row.find('td').get_text() for row in rows]\n",
"twoevils_df = pd.DataFrame(data={'name':twoevils_names,'url':url})\n",
"twoevils_df"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"Downloading names from https://www.twoevils.org/rollergirls/\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>url</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>!(ED</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>!Wolfespit</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>\"A\" Cup Annihilator</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>\"Bobby\" Val Halen</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>\"Chupa'clark'bra\"</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40537</th>\n",
" <td>Zuzi Power</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40538</th>\n",
" <td>Zwen Garden</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40539</th>\n",
" <td>Zyklon C</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40540</th>\n",
" <td>�Ss�</td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40541</th>\n",
" <td></td>\n",
" <td>https://www.twoevils.org/rollergirls/</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>40542 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" name url\n",
"0 !(ED https://www.twoevils.org/rollergirls/\n",
"1 !Wolfespit https://www.twoevils.org/rollergirls/\n",
"2 \"A\" Cup Annihilator https://www.twoevils.org/rollergirls/\n",
"3 \"Bobby\" Val Halen https://www.twoevils.org/rollergirls/\n",
"4 \"Chupa'clark'bra\" https://www.twoevils.org/rollergirls/\n",
"... ... ...\n",
"40537 Zuzi Power https://www.twoevils.org/rollergirls/\n",
"40538 Zwen Garden https://www.twoevils.org/rollergirls/\n",
"40539 Zyklon C https://www.twoevils.org/rollergirls/\n",
"40540 �Ss� https://www.twoevils.org/rollergirls/\n",
"40541   https://www.twoevils.org/rollergirls/\n",
"\n",
"[40542 rows x 2 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 436
},
"id": "IZn313h1VH3M",
"outputId": "a6b9e31b-8b66-4cd9-f6ea-6ecd4bc480cc"
},
"source": [
"url = \"http://www.derbyrollcall.com/everyone\"\n",
"print(\"Downloading names from %s\" % url)\n",
"r = session.get(url)\n",
"soup = BeautifulSoup(r.text, \"lxml\")\n",
"rows = soup.find_all('td', {'class':'name'})\n",
"drc_names = [td.get_text() for td in rows]\n",
"drc_df = pd.DataFrame(data={'name':drc_names,'url':url})\n",
"drc_df"
],
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"text": [
"Downloading names from http://www.derbyrollcall.com/everyone\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>url</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sausage Roller</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>James Mean</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Yvel Saint Laurent</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Pancake</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Robert Quadriguez</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37850</th>\n",
" <td>Rosannarchy</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37851</th>\n",
" <td>Karma Kali</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37852</th>\n",
" <td>LOUD Mary</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37853</th>\n",
" <td>Amy Roundhouse</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37854</th>\n",
" <td>Dino Whore</td>\n",
" <td>http://www.derbyrollcall.com/everyone</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>37855 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" name url\n",
"0 Sausage Roller http://www.derbyrollcall.com/everyone\n",
"1 James Mean http://www.derbyrollcall.com/everyone\n",
"2 Yvel Saint Laurent http://www.derbyrollcall.com/everyone\n",
"3 Pancake http://www.derbyrollcall.com/everyone\n",
"4 Robert Quadriguez http://www.derbyrollcall.com/everyone\n",
"... ... ...\n",
"37850 Rosannarchy http://www.derbyrollcall.com/everyone\n",
"37851 Karma Kali http://www.derbyrollcall.com/everyone\n",
"37852 LOUD Mary http://www.derbyrollcall.com/everyone\n",
"37853 Amy Roundhouse http://www.derbyrollcall.com/everyone\n",
"37854 Dino Whore http://www.derbyrollcall.com/everyone\n",
"\n",
"[37855 rows x 2 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 436
},
"id": "8cWhdy6cZLwD",
"outputId": "ca530e15-ea92-42d2-9afe-3e96ab939767"
},
"source": [
"url='https://resources.wftda.org/officiating/roller-derby-certification-program-for-officials/roster-of-certified-officials/'\n",
"print(\"Downloading names from {}\".format(url))\n",
"session.headers.update({'User-Agent':'Mozilla/5.0'})\n",
"r = session.get(url)\n",
"soup = BeautifulSoup(r.text, \"lxml\")\n",
"rows = soup.find_all('h5')\n",
"wftda_officials = [r.find('a').get_text() for r in rows]\n",
"wftda_df = pd.DataFrame({'name':wftda_officials,'url':url})\n",
"wftda_df"
],
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"text": [
"Downloading names from https://resources.wftda.org/officiating/roller-derby-certification-program-for-officials/roster-of-certified-officials/\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>url</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>9mm Ram-Paige</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>A. Grue</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>A’Blazing Grace</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Adam Smasher</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Admiral Mayhem</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>544</th>\n",
" <td>Yankee Rulz</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>545</th>\n",
" <td>Yvel Saint Laurent</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>546</th>\n",
" <td>Zebra 3</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>547</th>\n",
" <td>Zero</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>548</th>\n",
" <td>Zombie Dearest</td>\n",
" <td>https://resources.wftda.org/officiating/roller...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>549 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" name url\n",
"0 9mm Ram-Paige https://resources.wftda.org/officiating/roller...\n",
"1 A. Grue https://resources.wftda.org/officiating/roller...\n",
"2 A’Blazing Grace https://resources.wftda.org/officiating/roller...\n",
"3 Adam Smasher https://resources.wftda.org/officiating/roller...\n",
"4 Admiral Mayhem https://resources.wftda.org/officiating/roller...\n",
".. ... ...\n",
"544 Yankee Rulz https://resources.wftda.org/officiating/roller...\n",
"545 Yvel Saint Laurent https://resources.wftda.org/officiating/roller...\n",
"546 Zebra 3 https://resources.wftda.org/officiating/roller...\n",
"547 Zero https://resources.wftda.org/officiating/roller...\n",
"548 Zombie Dearest https://resources.wftda.org/officiating/roller...\n",
"\n",
"[549 rows x 2 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "boZuLM56VHv1",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "e07d0b98-8d58-4b5c-c12f-0ec1825d85db"
},
"source": [
"initial_letters = string.ascii_uppercase + string.digits + string.punctuation\n",
"print(initial_letters)\n",
"rdr_names = []\n",
"rdr_df = pd.DataFrame()\n",
"\n",
"def get_page_names(initial_letter, timeout=15):\n",
" temp_names = []\n",
" url = \"https://rollerderbyroster.com/view-names/?ini={}\".format(letter)\n",
" print(\"Downloading names from {}\".format(url))\n",
" try:\n",
" response = session.get(url=url, timeout=timeout)\n",
" r = session.get(url)\n",
" soup = BeautifulSoup(r.text, \"lxml\")\n",
" rows = soup.find_all('ul')\n",
" # Use only last unordered list - this is where names are!\n",
" for idx, li in enumerate(rows[-1]):\n",
" # Name should be the text of the link within the list item\n",
" name = li.find('a').get_text()\n",
" temp_names.append(name)\n",
" except requests.Timeout:\n",
" print(\" Timeout reading from {0}\".format(url))\n",
" pass\n",
" return temp_names\n",
"\n",
"for letter in initial_letters:\n",
" temp_names = get_page_names(initial_letter=letter)\n",
" rdr_names.extend(temp_names)\n",
" temp_df = pd.DataFrame(data={'name':temp_names, 'url':url})\n",
" rdr_df.append(temp_df)\n",
"\n",
"print(rdr_df)"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=A\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=B\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=C\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=D\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=E\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=F\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=G\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=H\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=I\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=J\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=K\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=L\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=M\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=N\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=O\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=P\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=Q\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=R\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=S\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=T\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=U\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=V\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=W\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=X\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=Y\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=Z\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=0\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=1\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=2\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=3\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=4\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=5\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=6\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=7\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=8\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=9\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=!\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=\"\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=#\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=$\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=%\n",
" Timeout reading from https://rollerderbyroster.com/view-names/?ini=%\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=&\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini='\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=(\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=)\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=*\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=+\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=,\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=-\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=.\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=/\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=:\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=;\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=<\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini==\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=>\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=?\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=@\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=[\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=\\\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=]\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=^\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=_\n",
" Timeout reading from https://rollerderbyroster.com/view-names/?ini=_\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=`\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini={\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=|\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=}\n",
"Downloading names from https://rollerderbyroster.com/view-names/?ini=~\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: []\n",
"Index: []"
]
},
"metadata": {
"tags": []
},
"execution_count": 9
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0gNRhesUVAT0",
"outputId": "dc8a4a16-937b-4e29-8973-5ea6fd59b8a5"
},
"source": [
"name_set = set(twoevils_names + drc_names + rdr_names + wftda_officials)\n",
"name_df = pd.concat([twoevils_df,drc_df,rdr_df,wftda_df],ignore_index=True)\n",
"# Remove \"cleared\" suffix\n",
"name_df['name'] = name_df['name'].str.rstrip('(cleared)')\n",
"name_df['name'] = name_df['name'].str.strip()\n",
"name_df.to_excel('derbynames_{0}.xlsx'.format(datetime.now().strftime('%Y%m%d')))\n",
"name_df.to_feather('derbynames_{0}.feather'.format(datetime.now().strftime('%Y%m%d')))\n",
"print(name_df)"
],
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"text": [
" name url\n",
"0 !(ED https://www.twoevils.org/rollergirls/\n",
"1 !Wolfespit https://www.twoevils.org/rollergirls/\n",
"2 \"A\" Cup Annihilato https://www.twoevils.org/rollergirls/\n",
"3 \"Bobby\" Val Halen https://www.twoevils.org/rollergirls/\n",
"4 \"Chupa'clark'bra\" https://www.twoevils.org/rollergirls/\n",
"... ... ...\n",
"78941 Yankee Rulz https://resources.wftda.org/officiating/roller...\n",
"78942 Yvel Saint Laurent https://resources.wftda.org/officiating/roller...\n",
"78943 Zebra 3 https://resources.wftda.org/officiating/roller...\n",
"78944 Zero https://resources.wftda.org/officiating/roller...\n",
"78945 Zombie Dearest https://resources.wftda.org/officiating/roller...\n",
"\n",
"[78946 rows x 2 columns]\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vW5XQP72WjE4",
"outputId": "8412d5b9-e977-4629-a216-d9ee02af72cd"
},
"source": [
"names_shuffled = pd.Series(shuffle(name_df['name'].unique()))\n",
"print(\"Writing {0} unique names to {1}\".format(len(names_shuffled),training_file.absolute()))\n",
"names_shuffled.to_csv(training_file,index=False,header=False)\n",
"names_shuffled"
],
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"text": [
"Writing 70642 unique names to /content/derby_names.txt\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 Dissonan\n",
"1 Whiskey Hangov\n",
"2 Zen's Adharm\n",
"3 Luna Lo\n",
"4 Elizabeth Mayhem\n",
" ... \n",
"70637 Skele-skate-ton\n",
"70638 Donkey Karnag\n",
"70639 Alyssa Smash\n",
"70640 Dollface Ki\n",
"70641 Kynna Getsum\n",
"Length: 70642, dtype: object"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "hivPLDl5C3zs"
},
"source": [
"model_cfg = {\n",
" 'word_level': False, # set to True if want to train a word-level model (requires more data and smaller max_length)\n",
" 'rnn_size': 256, # number of LSTM cells of each layer (128/256 recommended)\n",
" 'rnn_layers': 3, # number of LSTM layers (>=2 recommended)\n",
" 'rnn_bidirectional': True, # consider text both forwards and backward, can give a training boost\n",
" 'max_length': 20, # number of tokens to consider before predicting the next (20-40 for characters, 5-10 for words recommended)\n",
" 'max_words': 10000, # maximum number of words to model; the rest will be ignored (word-level model only)\n",
"}\n",
"\n",
"train_cfg = {\n",
" 'line_delimited': True, # set to True if each text has its own line in the source file\n",
" 'num_epochs': 40, # set higher to train the model for longer\n",
" 'gen_epochs': 5, # generates sample text from model after given number of epochs\n",
" 'train_size': 1.0, # proportion of input data to train on: setting < 1.0 limits model from learning perfectly\n",
" 'dropout': 0.5, # ignore a random proportion of source tokens each epoch, allowing model to generalize better\n",
" 'validation': False, # If train__size < 1.0, test on holdout dataset; will make overall training slower\n",
" 'is_csv': False # set to True if file is a CSV exported from Excel/BigQuery/pandas\n",
"}"
],
"execution_count": 12,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Wfg9-JRr09Z9",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "bab562b6-2b8e-47b9-911b-d70ad8b9a486"
},
"source": [
"textgen = textgenrnn(name=model_name)\n",
"\n",
"train_function = textgen.train_from_file if train_cfg['line_delimited'] else textgen.train_from_largetext_file\n",
"\n",
"train_function(\n",
" file_path=training_file,\n",
" new_model=True,\n",
" batch_size=1024,\n",
" dim_embeddings=100,\n",
" word_level=model_cfg['word_level'],\n",
" rnn_size=model_cfg['rnn_size'],\n",
" rnn_layers=model_cfg['rnn_layers'],\n",
" rnn_bidirectional=model_cfg['rnn_bidirectional'],\n",
" max_length=model_cfg['max_length'],\n",
" num_epochs=train_cfg['num_epochs'],\n",
" gen_epochs=train_cfg['gen_epochs'],\n",
" train_size=train_cfg['train_size'],\n",
" dropout=train_cfg['dropout'],\n",
" validation=train_cfg['validation'],\n",
" is_csv=train_cfg['is_csv'],\n",
")"
],
"execution_count": 13,
"outputs": [
{
"output_type": "stream",
"text": [
"70,642 texts collected.\n",
"Training new model w/ 3-layer, 256-cell Bidirectional LSTMs\n",
"Training on 909,122 character sequences.\n",
"Epoch 1/40\n",
"887/887 [==============================] - 313s 337ms/step - loss: 2.5619\n",
"Epoch 2/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 2.1580\n",
"Epoch 3/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 2.0260\n",
"Epoch 4/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.9464\n",
"Epoch 5/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.8843\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Shell Shock\n",
"\n",
"Betty Block\n",
"\n",
"Penny Pain\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Pony Pepp\n",
"\n",
"Stevie Blitz\n",
"\n",
"Broken Whip\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Lucky Nalmas\n",
"\n",
"Hell 67\n",
"\n",
"Death MC\n",
"\n",
"Epoch 6/40\n",
"887/887 [==============================] - 300s 338ms/step - loss: 1.8323\n",
"Epoch 7/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.7843\n",
"Epoch 8/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.7368\n",
"Epoch 9/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.6919\n",
"Epoch 10/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.6469\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Sugar Sku\n",
"\n",
"Slam ChaseH\n",
"\n",
"Shadow Sally\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Candy Disco\n",
"\n",
"Lady Miss Mayhem\n",
"\n",
"Roller Ros\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Eddie Cherry and breakH\n",
"\n",
"Scarlett Hooter Stars\n",
"\n",
"Pana B. Boag\n",
"\n",
"Epoch 11/40\n",
"887/887 [==============================] - 300s 338ms/step - loss: 1.6035\n",
"Epoch 12/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 1.5614\n",
"Epoch 13/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.5208\n",
"Epoch 14/40\n",
"887/887 [==============================] - 300s 337ms/step - loss: 1.4811\n",
"Epoch 15/40\n",
"887/887 [==============================] - 300s 337ms/step - loss: 1.4444\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Shocker Spi\n",
"\n",
"Shannon Bunny\n",
"\n",
"Sheriff of Destruction\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Jack Slamm\n",
"\n",
"Rican Marion\n",
"\n",
"Miss B Haven\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Emily Mornz\n",
"\n",
"Allie B. Inturn\n",
"\n",
"Hannahby Nell Hy\n",
"\n",
"Epoch 16/40\n",
"887/887 [==============================] - 299s 338ms/step - loss: 1.4087\n",
"Epoch 17/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.3759\n",
"Epoch 18/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.3432\n",
"Epoch 19/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.3125\n",
"Epoch 20/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.2842\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Sin D. Laph\n",
"\n",
"Slammin Sheen\n",
"\n",
"Sparkle Punch\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Pain in the Bass\n",
"\n",
"Liz Pain\n",
"\n",
"Sasha Straightjacket\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"KamiKazi Khaos\n",
"\n",
"Buck Tsunami\n",
"\n",
"Red Riding Too\n",
"\n",
"Epoch 21/40\n",
"887/887 [==============================] - 300s 338ms/step - loss: 1.2568\n",
"Epoch 22/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.2315\n",
"Epoch 23/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.2086\n",
"Epoch 24/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.1856\n",
"Epoch 25/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.1632\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Short Stir-Up\n",
"\n",
"Star Troop\n",
"\n",
"Mary Magdilem\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Barbara Co\n",
"\n",
"Bertolt Barbi\n",
"\n",
"Trouble Dutch\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Skay D. Vicious\n",
"\n",
"Hyperspoo\n",
"\n",
"Yameet Ur Doodlepants\n",
"\n",
"Epoch 26/40\n",
"887/887 [==============================] - 299s 337ms/step - loss: 1.1458\n",
"Epoch 27/40\n",
"887/887 [==============================] - 300s 337ms/step - loss: 1.1264\n",
"Epoch 28/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.1088\n",
"Epoch 29/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 1.0930\n",
"Epoch 30/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 1.0779\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Lil' Miss Potty Mouth\n",
"\n",
"Doomsday Dixi\n",
"\n",
"Dirty Deeds (Louis\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Mary Mangle-h\n",
"\n",
"Blacktears\n",
"\n",
"Hot Coco\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Ovary Cheevelh\n",
"\n",
"Tsunam\n",
"\n",
"Nikki Scrap\n",
"\n",
"Epoch 31/40\n",
"887/887 [==============================] - 300s 339ms/step - loss: 1.0635\n",
"Epoch 32/40\n",
"887/887 [==============================] - 301s 339ms/step - loss: 1.0503\n",
"Epoch 33/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.0391\n",
"Epoch 34/40\n",
"887/887 [==============================] - 301s 339ms/step - loss: 1.0270\n",
"Epoch 35/40\n",
"887/887 [==============================] - 301s 338ms/step - loss: 1.0158\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Sally SkullKrushn\n",
"\n",
"Steel MagnoLeah\n",
"\n",
"Star Spangled Slamm\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Carnage As\n",
"\n",
"General Pani\n",
"\n",
"Selena Go-Medz\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"Double DEMOLLY\n",
"\n",
"Sister Pisterpants\n",
"\n",
"Got Queen\n",
"\n",
"Epoch 36/40\n",
"887/887 [==============================] - 301s 339ms/step - loss: 1.0046\n",
"Epoch 37/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 0.9954\n",
"Epoch 38/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 0.9854\n",
"Epoch 39/40\n",
"887/887 [==============================] - 302s 339ms/step - loss: 0.9769\n",
"Epoch 40/40\n",
"887/887 [==============================] - 301s 339ms/step - loss: 0.9681\n",
"####################\n",
"Temperature: 0.2\n",
"####################\n",
"Shank Williams Jr.\n",
"\n",
"Shank Williams Jr.\n",
"\n",
"Star Spangled Hamm\n",
"\n",
"####################\n",
"Temperature: 0.5\n",
"####################\n",
"Cherry Bomb\n",
"\n",
"Captain Bearings\n",
"\n",
"Peaches N CreamH\n",
"\n",
"####################\n",
"Temperature: 1.0\n",
"####################\n",
"AzkaBAM!\n",
"\n",
"Pac-Jam\n",
"\n",
"Nicorette Scum\n",
"\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "AY-pMFlw4sYL",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 88
},
"outputId": "7a90f7cc-622d-4d63-c57a-1167856c34e3"
},
"source": [
"# changing the temperature schedule can result in wildly different output\n",
"# select TEMPS random temperatures ranging from MIN_TEMP to MAX_TEMP (higher = more \"creative\") \n",
"TEMPS = 10\n",
"MIN_TEMP = 0.2\n",
"MAX_TEMP = 1.0\n",
"temperature = []\n",
"\n",
"for i in range(TEMPS):\n",
" temp = round(random.uniform(MIN_TEMP, MAX_TEMP), 1)\n",
" temperature.append(temp)\n",
"\n",
"prefix = None # if you want each generated text to start with a given seed text\n",
"\n",
"if train_cfg['line_delimited']:\n",
" n = 250\n",
" max_gen_length = 60 if model_cfg['word_level'] else 300\n",
"else:\n",
" n = 25\n",
" max_gen_length = 2000 if model_cfg['word_level'] else 10000\n",
" \n",
"generated_names = textgen.generate(n=n, temperature=temperature, return_as_list=True)\n",
"\n",
"new_names = [n.rstrip('(cleared)') for n in generated_names if n not in name_set]\n",
"print(new_names)\n",
"\n",
"timestring = datetime.now().strftime('%Y%m%d_%H%M%S')\n",
"gen_file = '{0}_gentext_{1}_{2}.txt'.format(model_name, n, timestring)\n",
"\n",
"with open(gen_file, 'w') as f:\n",
" f.writelines(\"%s\\n\" % n for n in new_names)\n",
"\n",
"files.download(gen_file)"
],
"execution_count": 21,
"outputs": [
{
"output_type": "stream",
"text": [
"100%|██████████| 250/250 [02:56<00:00, 1.42it/s]"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"['Boston Bruze-H', 'Chick Chick BOOM Pow', 'Malicious Mous', 'Hot TaMau', 'Metal Mortici', 'Soul Crush', 'Slamabelle Lekto', \"Hannibal Deck'\", 'Machine Gun Maggi', 'Comic Ozi Moxi', 'Master Bak', \"Miss Shovin'\", 'Slammy Whipchest', 'Lil Miss Kamakaz', 'Greta Grow', 'Darth Mau', \"Block N'Deck'h\", 'Miss Mali', 'Miss Maulpracti', 'Smash N Barbi', 'Steph Met', 'Shred Ai', 'Double D. Fens', 'Short Shift H', 'Bash N Carri', 'Morticia Payn', 'Missy Kitty Rosenki', 'Strawberry Strang', 'Big Mam', 'Ballzy gine Trinity', 'Hells B', 'Pretty Peev', 'Galern', 'Black Banshee (Th', 'Hella Slam Witch', 'The Henchman', 'Kim Possib', 'Scar-A-Lott Fev', 'Happy Hou', 'Suzy Homewreck', 'Scorpion Kym', 'Melody Malli', 'Marilyn Monroadki', 'Suicide Blon', 'No Mercy M', 'Suzi SlamH', 'The Deathly H', 'Madame Seduce Y', 'SkellaWho', 'Shantastic McAwesom', 'Arctic Wolfsban', 'Wicked Whin', 'Torture Géni', 'Betty BoneDriv', 'Destructive Div', 'Shell Shock N Aw', 'The Mad Madame M', 'Scarlet Beav', 'Disco Warrio', 'Catch on Fi', 'Harley SlaughterHous', 'Tipsy Tea Bag', 'Chick Flai', 'Lady Beat', 'Stella Stallon', 'Lucky Lawless', 'Sista Fist', \"Cherry Bomb'\", 'The Jessicution', 'Twisted Mist', 'Sweet Sinfu', 'Paranoid Destroyy', 'Knotty Knitco', 'Shell Shin', 'Machine D', 'Betty Ballisti', 'Red Hot Snapp', 'Trixie Trax', 'Shirley Mittens', \"Lil' Edusk8o\", 'Internal ComeBustYa (in the f', 'Shell Shin', 'Brooke Meist', 'Rockette Scien', 'The Lock Ness Monst', 'Chica Lo', 'Holly Hotro', 'Petalli', 'Lil Smash', 'Pretty Miff', 'Bootiful Disast', 'Highway to K', 'Lone St', 'Carrie A. Grudg', 'Lil Miss Mugg', \"Devil Dog'n H\", 'Claudia Ripp', 'Booty Pag', 'Sin D. Wop-H', 'Rolling Redshirt', 'Charlie Bad Fi', 'Little Shorti', 'Demolition Div', 'Jenni Jam-Her-Som', \"Sweet Child O'Crim\", 'Punk E BruseH', 'Killer Groov', 'Betty Badhan', 'Triple D stroy', 'Shifty McFly', 'Dr. Dement', 'Billie Boilermak', 'Glitter Hitt', 'Darth Sm', 'Princess Fo', 'Betty Bomb', 'Abby Roadrash', 'Booty BumpH']\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
" async function download(id, filename, size) {\n",
" if (!google.colab.kernel.accessAllowed) {\n",
" return;\n",
" }\n",
" const div = document.createElement('div');\n",
" const label = document.createElement('label');\n",
" label.textContent = `Downloading \"${filename}\": `;\n",
" div.appendChild(label);\n",
" const progress = document.createElement('progress');\n",
" progress.max = size;\n",
" div.appendChild(progress);\n",
" document.body.appendChild(div);\n",
"\n",
" const buffers = [];\n",
" let downloaded = 0;\n",
"\n",
" const channel = await google.colab.kernel.comms.open(id);\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
"\n",
" for await (const message of channel.messages) {\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
" if (message.buffers) {\n",
" for (const buffer of message.buffers) {\n",
" buffers.push(buffer);\n",
" downloaded += buffer.byteLength;\n",
" progress.value = downloaded;\n",
" }\n",
" }\n",
" }\n",
" const blob = new Blob(buffers, {type: 'application/binary'});\n",
" const a = document.createElement('a');\n",
" a.href = window.URL.createObjectURL(blob);\n",
" a.download = filename;\n",
" div.appendChild(a);\n",
" a.click();\n",
" div.remove();\n",
" }\n",
" "
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"download(\"download_d4cc3481-87b4-460b-aad0-0b8472f9390c\", \"derbynames_gentext_250_20210527_164811.txt\", 1632)"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Cydo9Gro4zcz",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "440e14a5-95ea-4eeb-8f14-a141a77505bb"
},
"source": [
"model_zip = '{0}_model_{1}.zip'.format(model_name,datetime.now().strftime('%Y%m%d'))\n",
"model_files = [model_name + f for f in ('_vocab.json','_config.json','_weights.hdf5')]\n",
"\n",
"with ZipFile(model_zip, 'w') as zf:\n",
" for mf in model_files:\n",
" print(\" Adding {0} to {1}...\".format(mf,model_zip))\n",
" zf.write(mf)\n",
"\n",
"files.download(model_zip)"
],
"execution_count": 20,
"outputs": [
{
"output_type": "stream",
"text": [
" Adding derbynames_vocab.json to derbynames_model_20210527.zip...\n",
" Adding derbynames_config.json to derbynames_model_20210527.zip...\n",
" Adding derbynames_weights.hdf5 to derbynames_model_20210527.zip...\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
" async function download(id, filename, size) {\n",
" if (!google.colab.kernel.accessAllowed) {\n",
" return;\n",
" }\n",
" const div = document.createElement('div');\n",
" const label = document.createElement('label');\n",
" label.textContent = `Downloading \"${filename}\": `;\n",
" div.appendChild(label);\n",
" const progress = document.createElement('progress');\n",
" progress.max = size;\n",
" div.appendChild(progress);\n",
" document.body.appendChild(div);\n",
"\n",
" const buffers = [];\n",
" let downloaded = 0;\n",
"\n",
" const channel = await google.colab.kernel.comms.open(id);\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
"\n",
" for await (const message of channel.messages) {\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
" if (message.buffers) {\n",
" for (const buffer of message.buffers) {\n",
" buffers.push(buffer);\n",
" downloaded += buffer.byteLength;\n",
" progress.value = downloaded;\n",
" }\n",
" }\n",
" }\n",
" const blob = new Blob(buffers, {type: 'application/binary'});\n",
" const a = document.createElement('a');\n",
" a.href = window.URL.createObjectURL(blob);\n",
" a.download = filename;\n",
" div.appendChild(a);\n",
" a.click();\n",
" div.remove();\n",
" }\n",
" "
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"download(\"download_cbaadf17-75a1-4399-ae6a-a5d984c8e586\", \"derbynames_model_20210527.zip\", 16769722)"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {
"tags": []
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment