Spaces:
Sleeping
Sleeping
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 | |
# Define the style using Gradio's custom CSS feature | |
style = gr.Interface(fn=parse_text, inputs="text", outputs=["text", "number"], title="讙讬诇讜讬 驻住讜拽讬 讛转谞\"讱 讘讗诪爪注讜转 AI", | |
description="讛拽诇讬讚讜 讗转 讛讟拽住讟 砖转专爪讜, 讜讙诇讜 讛讗诐 讛讜讗 讗讻谉 诪讜驻讬注 讘转谞\"讱 讘讗诪爪注讜转 拽住诐 讛讘讬谞讛 讛诪诇讗讻讜转讬转", | |
theme="compact", allow_flagging="auto", | |
css=""".input-box {width: 90%; padding: 10px; margin-bottom: 15px; border: none; border-radius: 8px; background-color: #f2f2f2; color: #333; resize: none;} | |
.output-box {width: 90%; padding: 10px; border: none; border-radius: 8px; background-color: #f2f2f2; color: #333;} | |
.btn {width: 90%; padding: 10px; border: none; border-radius: 8px; background-color: #5d8d77; color: white; cursor: pointer; transition: background-color 0.3s ease-in-out;} | |
.btn:hover {background-color: #507b66;} | |
""") | |
style.launch() | |