Spaces:
Sleeping
Sleeping
File size: 956 Bytes
e2c9c4a 64a2354 3957c60 7923f38 e4071b9 e2c9c4a 0e6fd2c 64a2354 0e6fd2c 64a2354 8ab44c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
import nltk
from nltk.corpus import stopwords
import joblib
nltk.download('punkt')
# Load the trained model and vectorizer outside the function for better performance
loaded_classifier = joblib.load("bible_or_talmud_model.pkl")
vectorizer = joblib.load("bible_or_talmud_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 = max(probabilities[0])
labels = {0: '讗讞专', 1: '转谞"讱', 2: '转诇诪讜讚 讘讘诇讬'}
predicted_label = labels[prediction[0]]
return predicted_label, confidence_score
iface = gr.Interface(fn=parse_text, inputs="text", outputs=["text", "number"], title='讙讬诇讜讬 驻住讜拽讬 讛转谞"讱 讘讗诪爪注讜转 AI', description='讛讝谉 讟拽住讟 讻讚讬 诇住讜讜讙 讗诐 讛讜讗 诪讛转谞"讱 讗讜 诇讗.')
iface.launch()
|