Skip to content

Instantly share code, notes, and snippets.

@DGaffney
Created February 15, 2021 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DGaffney/0f9bcd1fdef27bdf72f2b0740c2522a1 to your computer and use it in GitHub Desktop.
Save DGaffney/0f9bcd1fdef27bdf72f2b0740c2522a1 to your computer and use it in GitHub Desktop.
import os
import json
import urllib
import pathlib
import requests
from aitextgen import aitextgen
manifest_url = "https://cdn.discordapp.com/attachments/810918431142576201/810936686250557511/manifest.json"
download_dir = "download"
pathlib.Path(download_dir).mkdir(parents=True, exist_ok=True)
def request(url, user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:85.0) Gecko/20100101 Firefox/85.0"):
return requests.get(url, headers={'user-agent': user_agent}).text
manifest = json.loads(json.loads(request(manifest_url)))
for file in manifest["urls_to_download"]:
content = request(file['response']['attachments'][0]['url'])
with open(download_dir+"/"+file['filename'], "w") as f:
f.write(content)
commands = [f"cat {download_dir}/base64_gpt2_split* > base64_gpt2_unsplit.bin", "base64 -d base64_gpt2_unsplit.bin > pytorch_rebuilt.bin", f"base64 -d {download_dir}/config_base64.json > config.json"]
for command in commands:
os.popen(command).read()
from aitextgen import aitextgen
ai = aitextgen(model="pytorch_rebuilt.bin", config="config.json")
ai.generate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment