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("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()