Spaces:
Sleeping
Sleeping
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) |