Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
-
|
2 |
import nltk
|
3 |
from nltk.corpus import stopwords
|
4 |
import joblib
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
# Load the trained model and vectorizer outside the routes for better performance
|
9 |
loaded_classifier = joblib.load("is_this_bible_model.pkl")
|
10 |
vectorizer = joblib.load("is_this_bible_vectorizer.pkl")
|
11 |
|
@@ -16,18 +14,5 @@ def parse_text(new_text):
|
|
16 |
confidence_score = probabilities[0, 1]
|
17 |
return 'ืชื "ื' if prediction[0] == 1 else 'ืืืจ', confidence_score
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
prediction = None
|
22 |
-
confidence_score = None
|
23 |
-
new_text = None
|
24 |
-
|
25 |
-
if request.method == 'POST':
|
26 |
-
new_text = request.form['new_text']
|
27 |
-
if new_text:
|
28 |
-
prediction, confidence_score = parse_text(new_text)
|
29 |
-
return render_template('index.html', new_text=new_text, prediction=prediction, confidence_score=confidence_score)
|
30 |
-
|
31 |
-
|
32 |
-
if __name__ == '__main__':
|
33 |
-
app.run(debug=True, host='0.0.0.0')
|
|
|
1 |
+
import gradio as gr
|
2 |
import nltk
|
3 |
from nltk.corpus import stopwords
|
4 |
import joblib
|
5 |
|
6 |
+
# Load the trained model and vectorizer outside the function for better performance
|
|
|
|
|
7 |
loaded_classifier = joblib.load("is_this_bible_model.pkl")
|
8 |
vectorizer = joblib.load("is_this_bible_vectorizer.pkl")
|
9 |
|
|
|
14 |
confidence_score = probabilities[0, 1]
|
15 |
return 'ืชื "ื' if prediction[0] == 1 else 'ืืืจ', confidence_score
|
16 |
|
17 |
+
iface = gr.Interface(fn=parse_text, inputs="text", outputs=["text", "number"], title="Bible Text Classifier", description='ืืื ืืงืกื ืืื ืืกืืื ืื ืืื ืืืชื "ื ืื ืื.')
|
18 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|