detect_topics / app.py
rdlf's picture
Create app.py
8dba805 verified
raw
history blame
566 Bytes
import gradio as gr
import io
from bertopic import BERTopic
def detect_topics(file):
if file is not None:
text = file.read()
text = text.decode('utf-8')
topic_model = BERTopic()
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=gr.inputs.File(label="Upload File"),
outputs="text")
iface.launch(debug=True)