NHLOCAL commited on
Commit
e2c9c4a
โ€ข
1 Parent(s): e105785

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -19
app.py CHANGED
@@ -1,11 +1,9 @@
1
- from flask import Flask, render_template, request
2
  import nltk
3
  from nltk.corpus import stopwords
4
  import joblib
5
 
6
- app = Flask(__name__)
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
- @app.route('/', methods=['GET', 'POST'])
20
- def index():
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()