NewsTruth / app.py
Rehman1603's picture
Update app.py
53d13bf
import pickle
import gradio as gr
from sklearn.feature_extraction.text import TfidfVectorizer
Tfid=TfidfVectorizer()
with open("News_Model.pkl","rb") as f:
model_info=pickle.load(f)
with open("Vector.pkl","rb") as f:
vector_info=pickle.load(f)
def News_Prediction(news):
input_data=[news]
vector_form=vector_info.transform(input_data)
result=model_info.predict(vector_form)
if(result[0]==0):
ans="It is Fake News"
else:
ans="It is Real News"
return ans
interface=gr.Interface(fn=News_Prediction,inputs=[gr.components.Textbox(lines=2,placeholder="News...",label="Enter News")],
outputs=[gr.components.Textbox(label="Your Result")],
examples=[
["Sunday night's Democratic debate comes at a crucial moment. The two front-runners β€” Hillary Clinton and Bernie Sanders β€” are closer in the polls than ever, and the Iowa caucus is only two weeks away.Up until now, Clinton has done well in debates; it's a format that suits her. But Sanders' message is breaking through, and he's gaining in the polls nationally, leads in New Hampshire and is neck and neck with Clinton in Iowa. That means the pressure is on for both candidates Sunday night. The debate, taking place in Charleston, S.C., begins at 9 p.m. EST. The NBC/YouTube/Congressional Black Caucus Institute debate will air on NBC broadcast stations and livestreamed on NBC digital platforms, including its YouTube channel."]
]
)
interface.launch(debug=True)