|
import gradio as gr |
|
import joblib |
|
|
|
|
|
|
|
|
|
model = joblib.load('lgbm_model.pkl') |
|
vectorizer = joblib.load('vectorizer.pkl') |
|
|
|
def classify_text(text): |
|
|
|
text_vector = vectorizer.transform([text]) |
|
|
|
|
|
prediction = model.predict(text_vector) |
|
|
|
return int(prediction[0]) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=classify_text, |
|
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), |
|
outputs=gr.Label(), |
|
title="Fake News Classifier", |
|
description="Enter text to classify if it's fake (1) or not fake (0).", |
|
examples=["This is a sample news article."] |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|