Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import io
|
| 3 |
from bertopic import BERTopic
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
def detect_topics(file):
|
| 6 |
if file is not None:
|
| 7 |
text = file.read()
|
| 8 |
text = text.decode('utf-8')
|
| 9 |
|
| 10 |
-
|
| 11 |
topics, probs = topic_model.fit_transform(texts)
|
| 12 |
df_topic = topic_model.get_topic_info()
|
| 13 |
#df_topic.to_csv('topics.csv')
|
| 14 |
return (topic_model.visualize_topics())
|
| 15 |
|
| 16 |
#UI file
|
| 17 |
-
iface = gr.Interface(fn=detect_topics,
|
| 18 |
-
inputs=gr.inputs.File(label="Upload File"),
|
| 19 |
-
outputs="text")
|
| 20 |
|
| 21 |
iface.launch(debug=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import io
|
| 3 |
from bertopic import BERTopic
|
| 4 |
+
input = gr.File(label="Input Text File")
|
| 5 |
+
output = gr.Textbox(label="Detected Topics")
|
| 6 |
+
topic_model = BERTopic()
|
| 7 |
def detect_topics(file):
|
| 8 |
if file is not None:
|
| 9 |
text = file.read()
|
| 10 |
text = text.decode('utf-8')
|
| 11 |
|
| 12 |
+
|
| 13 |
topics, probs = topic_model.fit_transform(texts)
|
| 14 |
df_topic = topic_model.get_topic_info()
|
| 15 |
#df_topic.to_csv('topics.csv')
|
| 16 |
return (topic_model.visualize_topics())
|
| 17 |
|
| 18 |
#UI file
|
| 19 |
+
iface = gr.Interface(fn=detect_topics, inputs=input, outputs=output)
|
|
|
|
|
|
|
| 20 |
|
| 21 |
iface.launch(debug=True)
|