Update app.py
Browse files
app.py
CHANGED
|
@@ -1,60 +1,20 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
-
from
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
from modules.inference import infer_t5
|
| 9 |
-
from modules.dataset import query_emotion
|
| 10 |
-
|
| 11 |
-
# https://huggingface.co/settings/tokens
|
| 12 |
-
# https://huggingface.co/spaces/{username}/{space}/settings
|
| 13 |
-
API_TOKEN = os.getenv("BIG_GAN_TOKEN")
|
| 14 |
-
|
| 15 |
-
app = Flask(__name__)
|
| 16 |
-
|
| 17 |
|
| 18 |
@app.route("/")
|
| 19 |
-
def
|
| 20 |
-
return render_template(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
data=json.dumps(input),
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
return send_file(BytesIO(output.content), mimetype="image/png")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
@app.route("/infer_t5")
|
| 38 |
-
def t5():
|
| 39 |
-
input = request.args.get("input")
|
| 40 |
-
|
| 41 |
-
output = infer_t5(input)
|
| 42 |
-
|
| 43 |
-
return jsonify({"output": output})
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
@app.route("/query_emotion")
|
| 47 |
-
def emotion():
|
| 48 |
-
start = request.args.get("start")
|
| 49 |
-
end = request.args.get("end")
|
| 50 |
-
|
| 51 |
-
print(start)
|
| 52 |
-
print(end)
|
| 53 |
-
|
| 54 |
-
output = query_emotion(int(start), int(end))
|
| 55 |
-
|
| 56 |
-
return jsonify({"output": output})
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
if __name__ == "__main__":
|
| 60 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
+
from flask import Flask,render_template, request
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__,template_folder="templates")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@app.route("/")
|
| 9 |
+
def hello():
|
| 10 |
+
return render_template('index.html')
|
| 11 |
+
|
| 12 |
+
@app.route('/process', methods=['POST'])
|
| 13 |
+
def process():
|
| 14 |
+
data = request.form.get('data')
|
| 15 |
+
# process the data using Python code
|
| 16 |
+
result = data.upper()
|
| 17 |
+
return result
|
| 18 |
+
|
| 19 |
+
if __name__ == '__main__':
|
| 20 |
+
app.run(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|