diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3fa9317 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +Dockerfile +README.md +*.pyc +*.pyo +__pycache__ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1426756 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM nvcr.io/nvidia/tensorflow:19.08-py3 + +ENV APP_HOME /app +WORKDIR $APP_HOME +COPY . ./ + +RUN pip install -r requirements.txt +WORKDIR generator/ctrl +RUN ls +RUN sh install_ctrl_py3.sh +RUN sh download_model.sh +WORKDIR $APP_HOME + +CMD exec guincorn --bind :%PORT --workers 1 --threads 8 app:app diff --git a/console_play.py b/console_play.py index f11a3c1..023b4d8 100644 --- a/console_play.py +++ b/console_play.py @@ -29,11 +29,14 @@ def play_unconstrained(): story_manager.start_new_story(prompt, context=context) print("\n") + print(context) console_print(str(story_manager.story)) while (True): action = input("> ") if action != "": + action = action.strip() + action = action[0].lower() + action[1:] if action[-1] == "." or action[-1] == "?" or action[-1] == "!": diff --git a/data/app.py b/data/app.py new file mode 100644 index 0000000..274d64b --- /dev/null +++ b/data/app.py @@ -0,0 +1,13 @@ +import os +import flask +import Flask +app = Flask(__name__) + +@app.route("/") +def hellp_world(): + target = os.environ.get('TARGET', 'World') + return 'Hello {}!\n'.format(target) + + +if __name__ == "__main__": + app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080))) diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index f979274..12fccce 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -23,7 +23,7 @@ class CTRLGenerator(): def __init__(self, control_code="Apocalypse ", generate_num=28, temperature=0.5, topk=40, nucleus_prob=0): self.generate_num=generate_num - model_dir = "generator/ctrl/training_utils/seqlen256_v1.ckpt/" + model_dir = "generator/ctrl/model/aidungeon2model/" self.control_code = control_code vocab_file = 'generator/ctrl/model/vocab' code_file = 'generator/ctrl/model/codes' diff --git a/generator/ctrl/download_model.sh b/generator/ctrl/download_model.sh index e002f85..2be278d 100755 --- a/generator/ctrl/download_model.sh +++ b/generator/ctrl/download_model.sh @@ -1,8 +1,4 @@ -curl https://sdk.cloud.google.com | bash -exec -l $SHELL -gcloud init +URL="gs://aidungeon2model" -URL="gs://sf-ctrl/seqlen512_v1.ckpt/" - -gsutil -m cp -r "$URL" model +gsutil -m cp -r "$URL" model diff --git a/generator/ctrl/download_training_data.sh b/generator/ctrl/download_training_data.sh deleted file mode 100755 index 6c5fba8..0000000 --- a/generator/ctrl/download_training_data.sh +++ /dev/null @@ -1,3 +0,0 @@ -URL="gs://first-person-fantasy/merged-first-person.txt" - -gsutil -m cp -r "$URL" training_utils diff --git a/generator/ctrl/install_gcloud.sh b/generator/ctrl/install_gcloud.sh new file mode 100644 index 0000000..a3c6455 --- /dev/null +++ b/generator/ctrl/install_gcloud.sh @@ -0,0 +1,3 @@ +curl https://sdk.cloud.google.com | bash +exec -l $SHELL +gcloud init diff --git a/generator/tf/models/117M/model.ckpt.index b/generator/tf/models/117M/model.ckpt.index deleted file mode 100644 index 24729aa..0000000 Binary files a/generator/tf/models/117M/model.ckpt.index and /dev/null differ diff --git a/generator/tf/models/117M/model.ckpt.meta b/generator/tf/models/117M/model.ckpt.meta deleted file mode 100644 index 2541738..0000000 Binary files a/generator/tf/models/117M/model.ckpt.meta and /dev/null differ diff --git a/generator/tf/models/774M/model.ckpt.index b/generator/tf/models/774M/model.ckpt.index deleted file mode 100644 index 974acbf..0000000 Binary files a/generator/tf/models/774M/model.ckpt.index and /dev/null differ diff --git a/generator/tf/models/774M/model.ckpt.meta b/generator/tf/models/774M/model.ckpt.meta deleted file mode 100644 index f5fea4f..0000000 Binary files a/generator/tf/models/774M/model.ckpt.meta and /dev/null differ diff --git a/story/utils.py b/story/utils.py index 83ddbd5..1ea66d8 100644 --- a/story/utils.py +++ b/story/utils.py @@ -126,6 +126,13 @@ first_to_second_mappings = [ ("I'd", "you'd"), ("i", "you"), ("I've", "you've"), + ("was I", "were you"), + ("am I", "are you"), + ("wasn't I", "weren't you"), + ("I", "you"), + ("I'd", "you'd"), + ("i", "you"), + ("I've", "you've"), ("I was", "you were"), ("my", "your"), ("we","you"), @@ -207,4 +214,4 @@ if __name__ == '__main__': while ("\n \n \n " in result): result = result.replace("\n \n \n ", "\n \n ") - print(result) \ No newline at end of file + print(result)