Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from sklearn.feature_extraction.text import CountVectorizer
|
3 |
+
import joblib
|
4 |
+
|
5 |
+
vectorizer = CountVectorizer()
|
6 |
+
nb_classifier = joblib.load('./nb_classifier.pkl')
|
7 |
+
def classify(text):
|
8 |
+
corpus=[text]
|
9 |
+
features = vectorizer.transform(corpus)
|
10 |
+
features = features.toarray()
|
11 |
+
prediction = nb_classifier.predict(features)
|
12 |
+
if(prediction == 1):
|
13 |
+
return "Fake News"
|
14 |
+
else:
|
15 |
+
return "Not Fake News"
|
16 |
+
|
17 |
+
GUI = gr.Interface(inputs = ['text'], outputs = ['text'], fn = classify, title = "Fake News Detection System")
|
18 |
+
GUI.launch()
|