Spaces:
Sleeping
Sleeping
Commit
•
d4952da
0
Parent(s):
Duplicate from bsenst/flask_inference_api
Browse filesCo-authored-by: Benjamin Senst <bsenst@users.noreply.huggingface.co>
- .gitattributes +27 -0
- README.md +14 -0
- app.py +26 -0
- index.html +14 -0
- requirements.txt +4 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Flask_test
|
3 |
+
emoji: 🦀
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 2.8.13
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: bsenst/flask_inference_api
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import flask
|
2 |
+
from flask import request
|
3 |
+
import os
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
load_dotenv()
|
6 |
+
|
7 |
+
app = flask.Flask(__name__, template_folder="./")
|
8 |
+
|
9 |
+
from transformers import pipeline
|
10 |
+
|
11 |
+
classifier = pipeline('text-classification', model="bsenst/classify_services_model")
|
12 |
+
|
13 |
+
@app.route('/')
|
14 |
+
def index():
|
15 |
+
return flask.render_template('index.html')
|
16 |
+
|
17 |
+
@app.route("/", methods=["POST"])
|
18 |
+
def predict():
|
19 |
+
incoming = request.get_json()
|
20 |
+
print(incoming)
|
21 |
+
prediction = classifier(incoming["text"])[0]
|
22 |
+
print(prediction)
|
23 |
+
return prediction
|
24 |
+
|
25 |
+
if __name__ == '__main__':
|
26 |
+
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
index.html
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h1>
|
2 |
+
Flask Space
|
3 |
+
</h1>
|
4 |
+
|
5 |
+
<p>
|
6 |
+
Welcome! This is a Flask Space! To create one, follow the next steps:
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<ol>
|
10 |
+
<li>Create a <a href="https://huggingface.co/new-space">new Space</a></li>
|
11 |
+
<li>Select Gradio SDK</li>
|
12 |
+
<li>Add Flask to the requirements</li>
|
13 |
+
<li>Create your Flask app in app.py file</li>
|
14 |
+
</ol>
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Flask==2.0.2
|
2 |
+
python-dotenv==0.19.2
|
3 |
+
transformers
|
4 |
+
torch
|