File size: 695 Bytes
ae4dfbe
c2c7c25
 
 
 
ae4dfbe
 
 
c2c7c25
ae4dfbe
 
 
 
 
 
 
c2c7c25
 
ae4dfbe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from transformers import AutoModel, AutoTokenizer
from flask import Flask, request, jsonify

app = Flask(__name__)

# Load model and tokenizer from Hugging Face Hub
tokenizer = AutoTokenizer.from_pretrained("Erfan11/Neuracraft", use_auth_token="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")
model = AutoModel.from_pretrained("Erfan11/Neuracraft", use_auth_token="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")

@app.route('/predict', methods=['POST'])
def predict():
    data = request.get_json()
    inputs = tokenizer(data["text"], return_tensors="pt")
    outputs = model(**inputs)
    # Process your model's output as needed
    return jsonify(outputs)

if __name__ == '__main__':
    app.run(debug=True)