awacke1 commited on
Commit
f0a7780
·
1 Parent(s): bb41e26

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import transformers
3
+ import numpy as np
4
+
5
+ # Load the pre-trained model
6
+ model = transformers.pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-topic-modeling")
7
+
8
+ # Define the Streamlit app
9
+ def main():
10
+ st.title("Topic Modeling with Hugging Face")
11
+ text = st.text_area("Enter some text to generate topics", height=200)
12
+
13
+ if st.button("Generate Topics"):
14
+ # Generate topics
15
+ topics = model(text, max_length=50, do_sample=True, num_beams=5, temperature=0.7)
16
+
17
+ # Print topics
18
+ st.write("Top 5 topics:")
19
+ for i in range(5):
20
+ st.write(f"{i+1}. {topics[i]['generated_text']}")
21
+
22
+ if __name__ == "__main__":
23
+ main()