Manish-4007 commited on
Commit
528ab98
·
1 Parent(s): db6f361
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -10,7 +10,7 @@ def load_topic_transfomers():
10
  print("Error: ", e)
11
  return topic_classifier
12
 
13
- def suggest_topic(text):
14
 
15
  # while len(text)> 1024:
16
  # text = summarize(whole_text[:-10])
@@ -26,16 +26,19 @@ st.title("Topic Suggestion")
26
 
27
  if 'topic_model' not in st.session_state:
28
  with st.spinner("Loading Model....."):
29
- topic_classifier = load_topic_transfomers()
30
  st.success("Model_loaded")
31
- st.session_state.topic_model = True
32
 
33
  whole_text = st.text_input("Enter the text Here: ")
34
 
35
  try:
36
- predicted_topic = suggest_topic(whole_text)
 
 
 
37
 
38
- st.write('Suggested Topics')
39
  for i in predicted_topic[:10]:
40
  st.write(i)
41
  except Exception as e:
 
10
  print("Error: ", e)
11
  return topic_classifier
12
 
13
+ def suggest_topic(topic_classifier,text):
14
 
15
  # while len(text)> 1024:
16
  # text = summarize(whole_text[:-10])
 
26
 
27
  if 'topic_model' not in st.session_state:
28
  with st.spinner("Loading Model....."):
29
+ st.session_state.topic_model = load_topic_transfomers()
30
  st.success("Model_loaded")
31
+ st.session_state.model = True
32
 
33
  whole_text = st.text_input("Enter the text Here: ")
34
 
35
  try:
36
+ if st.button('Suggest topic'):
37
+ with st.spinner(Scanning content to suggest topics):
38
+ topic_classifier = st.session_state.topic_model
39
+ predicted_topic = suggest_topic(topic_classifier,whole_text)
40
 
41
+ st.subheader('Top 10 Topics related to the content')
42
  for i in predicted_topic[:10]:
43
  st.write(i)
44
  except Exception as e: