initial commit
Browse files- app.py +34 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import lightgbm as lgb
|
3 |
+
import joblib
|
4 |
+
|
5 |
+
# Load your trained model (assuming it's saved as 'lgbm_model.pkl')
|
6 |
+
model = joblib.load('lgbm_model.pkl')
|
7 |
+
|
8 |
+
def classify_text(text):
|
9 |
+
# Convert the input text to the appropriate format for your model
|
10 |
+
# For simplicity, let's assume you have a function `preprocess_text` for this
|
11 |
+
# processed_text = preprocess_text(text)
|
12 |
+
|
13 |
+
# If your model expects numerical features, convert text to numerical features
|
14 |
+
# For example:
|
15 |
+
# features = text_to_features(processed_text)
|
16 |
+
|
17 |
+
# Here, we assume the model can take raw text directly for simplicity
|
18 |
+
prediction = model.predict([text])
|
19 |
+
|
20 |
+
return int(prediction[0])
|
21 |
+
|
22 |
+
# Create the Gradio interface
|
23 |
+
iface = gr.Interface(
|
24 |
+
fn=classify_text,
|
25 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
26 |
+
outputs=gr.outputs.Label(num_top_classes=1),
|
27 |
+
title="Fake News Classifier",
|
28 |
+
description="Enter text to classify if it's fake (1) or not fake (0).",
|
29 |
+
examples=["This is a sample news article."]
|
30 |
+
)
|
31 |
+
|
32 |
+
# Launch the interface
|
33 |
+
if __name__ == "__main__":
|
34 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
lightgbm
|