Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from bertopic import BERTopic
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Load your trained topic model
|
| 5 |
+
model = BERTopic.load("topic_model")
|
| 6 |
+
|
| 7 |
+
def predict_topic(text):
|
| 8 |
+
topics, _ = model.transform([text])
|
| 9 |
+
return str(topics[0])
|
| 10 |
+
|
| 11 |
+
iface = gr.Interface(
|
| 12 |
+
fn=predict_topic,
|
| 13 |
+
inputs=gr.Textbox(label="Enter text"),
|
| 14 |
+
outputs=gr.Textbox(label="Predicted Topic"),
|
| 15 |
+
title="AFCON Topic Detection"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
iface.launch()
|