Spaces:
Sleeping
Sleeping
Create App.py
Browse files
App.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import TFBertForSequenceClassification, BertTokenizer
|
2 |
+
from flask import Flask, request, jsonify
|
3 |
+
import os
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
|
7 |
+
# Load model and tokenizer from Hugging Face Hub
|
8 |
+
model_name = "Erfan11/Neuracraft"
|
9 |
+
model = TFBertForSequenceClassification.from_pretrained(model_name, from_tf=True, use_auth_token="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")
|
10 |
+
tokenizer = BertTokenizer.from_pretrained(model_name, use_auth_token="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")
|
11 |
+
|
12 |
+
@app.route('/predict', methods=['POST'])
|
13 |
+
def predict():
|
14 |
+
data = request.get_json()
|
15 |
+
inputs = tokenizer(data["text"], return_tensors="tf")
|
16 |
+
outputs = model(**inputs)
|
17 |
+
# Process your model's output as needed
|
18 |
+
return jsonify(outputs)
|
19 |
+
|
20 |
+
if __name__ == '__main__':
|
21 |
+
app.run(debug=True)
|