Spaces:
Sleeping
Sleeping
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() | |