Created
May 24, 2019 05:12
-
-
Save rish-16/2d498ca60a848e6015bd13d36368d3b5 to your computer and use it in GitHub Desktop.
Our GPT-2 model server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| from flask import Flask, request | |
| from interactive_conditional_samples import interact_model | |
| app = Flask(__name__) | |
| @app.route('/', methods=['GET']) | |
| def hello(): | |
| return "Hello from GPT-2 model server!" | |
| """ | |
| This is where the raw text is sent | |
| The `interact_model` can be found under the `gpt-2/src` directory | |
| in the `interactive_conditional_samples.py` code | |
| """ | |
| @app.route('/generate', methods=['POST']) | |
| def generate(): | |
| text = request.data.decode('utf-8') | |
| model_path = './models/' | |
| final_text = interact_model(raw_text=text, models_dir=model_path) | |
| return final_text | |
| if __name__ == '__main__': | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment