Textwizai / App.py
Erfan11's picture
Create App.py
732d546 verified
raw
history blame
777 Bytes
from transformers import TFBertForSequenceClassification, BertTokenizer
from flask import Flask, request, jsonify
import os
app = Flask(__name__)
# Load model and tokenizer from Hugging Face Hub
model_name = "Erfan11/Neuracraft"
model = TFBertForSequenceClassification.from_pretrained(model_name, from_tf=True, use_auth_token="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")
tokenizer = BertTokenizer.from_pretrained(model_name, use_auth_token="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")
@app.route('/predict', methods=['POST'])
def predict():
data = request.get_json()
inputs = tokenizer(data["text"], return_tensors="tf")
outputs = model(**inputs)
# Process your model's output as needed
return jsonify(outputs)
if __name__ == '__main__':
app.run(debug=True)