taitbaha commited on
Commit
659cdde
1 Parent(s): 9186406

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from bertopic import BERTopic
3
+
4
+ # Load the trained BERTopic model
5
+ model_path = "TarekAi/ArBERTopic"
6
+ topic_model = BERTopic.load(model_path)
7
+
8
+ # Streamlit app
9
+ st.title("BERTopic Inference")
10
+ st.write("Enter a single idea to get the predicted topic and its probabilities.")
11
+
12
+ document = st.text_area("Enter your idea here...", height=200)
13
+
14
+ if st.button("Predict Topic"):
15
+ if document:
16
+ topics, probabilities = topic_model.transform([document])
17
+ st.write(f"Predicted Topic: {topics[0]}")
18
+ st.write(f"Probabilities: {probabilities[0].tolist()}")
19
+ else:
20
+ st.write("Please enter a valid idea.")