-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (36 loc) · 1.12 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import nltk
import string
from tqdm import tqdm
import numpy as np
#import pandas as pd
import pandas as pd
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import pickle
from flask import Flask,render_template,url_for,request
from keras.models import load_model
# import tensorflow as tf
# from keras.utils import np_utils
# from tensorflow.keras.models import Sequential
# from tensorflow.keras.utils import to_categorical
# from tensorflow.keras.layers import Dense, Dropout, Activation
from nltk.corpus import stopwords
#
filename='model.pickle'
#clf=open(filename,'rb')
clf=load_model('swahili.h5')
cv=pickle.load(open('vectorizer.pickle','rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/predict',methods=['POST'])
def predict():
if request.method =='POST':
message=request.form['message']
data=[message]
vect=cv.transform(data).toarray()
my_prediction=np.argmax(clf.predict(vect),axis=1)
return render_template('result.html',prediction=my_prediction)
if __name__ == '__main__':
app.run(debug=True)