File size: 641 Bytes
659cdde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
from bertopic import BERTopic

# Load the trained BERTopic model
model_path = "TarekAi/ArBERTopic"
topic_model = BERTopic.load(model_path)

# Streamlit app
st.title("BERTopic Inference")
st.write("Enter a single idea to get the predicted topic and its probabilities.")

document = st.text_area("Enter your idea here...", height=200)

if st.button("Predict Topic"):
    if document:
        topics, probabilities = topic_model.transform([document])
        st.write(f"Predicted Topic: {topics[0]}")
        st.write(f"Probabilities: {probabilities[0].tolist()}")
    else:
        st.write("Please enter a valid idea.")