File size: 777 Bytes
732d546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)