File size: 817 Bytes
e2c9c4a
64a2354
 
 
3957c60
e2c9c4a
64a2354
 
 
 
 
 
 
 
 
 
e2c9c4a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
import nltk
from nltk.corpus import stopwords
import joblib

# Load the trained model and vectorizer outside the function for better performance
loaded_classifier = joblib.load("is_this_bible_model.pkl")
vectorizer = joblib.load("is_this_bible_vectorizer.pkl")

def parse_text(new_text):
    new_text_tfidf = vectorizer.transform([new_text])
    prediction = loaded_classifier.predict(new_text_tfidf)
    probabilities = loaded_classifier.predict_proba(new_text_tfidf)
    confidence_score = probabilities[0, 1]
    return '转谞"讱' if prediction[0] == 1 else '讗讞专', confidence_score

iface = gr.Interface(fn=parse_text, inputs="text", outputs=["text", "number"], title="Bible Text Classifier", description='讛讝谉 讟拽住讟 讻讚讬 诇住讜讜讙 讗诐 讛讜讗 诪讛转谞"讱 讗讜 诇讗.')
iface.launch()