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