Yousfi101 commited on
Commit
eb71970
1 Parent(s): 196ed89

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ from sklearn.feature_extraction.text import TfidfVectorizer
4
+
5
+
6
+ with open("News_Model.pkl","rb") as f:
7
+ model_info=pickle.load(f)
8
+
9
+ with open("Vector.pkl","rb") as f:
10
+ vector_info=pickle.load(f)
11
+
12
+ def News_Prediction(news):
13
+ input_data=[news]
14
+ vector_form=vector_info.transform(input_data)
15
+ result=model_info.predict(vector_form)
16
+ if(result[0]==0):
17
+ ans="It is Fake News"
18
+ else:
19
+ ans="It is Real News"
20
+ return ans
21
+
22
+
23
+ interface=gr.Interface(fn=News_Prediction,inputs=[gr.components.Textbox(lines=2,placeholder="News...",label="Enter News")],
24
+ outputs=[gr.components.Textbox(label="Your Result")],
25
+ examples=[
26
+ ["In 1999, Sharif was overthrown by a military coup that brought army chief General Pervez Musharraf to power. Sharif subsequently went into exile in Saudi Arabia, before returning to Pakistan in 2007 as Musharraf's grip on power began to slip."]
27
+ ]
28
+ )
29
+
30
+ interface.launch(debug=True)