File size: 861 Bytes
24bf069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Flask, request, render_template, jsonify
from predict import predict_language
import joblib
import tensorflow as tf
import h5py

model = tf.keras.models.load_model('models\\full_language_identifcation_modelf.h5')
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
CountVectorizer = joblib.load('models\\cv.joblib')
LabelEncoder = joblib.load('models\\le.joblib')


app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def predict():
    if request.method == 'POST':
        text = request.form['text']
        prediction = predict_language(text, model, CountVectorizer, LabelEncoder)  # Call your prediction function
        return render_template('result.html', prediction=prediction, text=text)
    return render_template('index.html')

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