rdlf commited on
Commit
8dba805
·
verified ·
1 Parent(s): 326dd4d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +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
+ topic_model = BERTopic()
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)