Emily666666 commited on
Commit
c7770a0
·
verified ·
1 Parent(s): c2261a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -30,19 +30,19 @@ if st.button("Process"):
30
  # Perform text summarization
31
  summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
32
  summarized_text = summary[0]['summary_text']
33
- # Display the summary result
34
- st.write("Summarized Text:", summarized_text)
35
  except Exception as e:
36
  st.error(f"Error during summarization: {e}")
37
 
38
- try:
39
- # Perform question classification on the summarized text
40
- results = classifier(summarized_text)[0]
41
- # Find the category with the highest score
42
- max_score = max(results, key=lambda x: x['score'])
43
- st.write("Category:", max_score['label'])
44
- st.write("Score:", max_score['score'])
45
- except Exception as e:
46
- st.error(f"Error during classification: {e}")
 
 
47
  else:
48
  st.warning("Please enter text to process and ensure both models are loaded.")
 
30
  # Perform text summarization
31
  summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
32
  summarized_text = summary[0]['summary_text']
 
 
33
  except Exception as e:
34
  st.error(f"Error during summarization: {e}")
35
 
36
+ if summarized_text:
37
+ try:
38
+ # Perform question classification on the summarized text
39
+ results = classifier(summarized_text)[0]
40
+ # Find the category with the highest score
41
+ max_score = max(results, key=lambda x: x['score'])
42
+ st.write("Summarized Text:", summarized_text)
43
+ st.write("Category:", max_score['label'])
44
+ st.write("Score:", max_score['score'])
45
+ except Exception as e:
46
+ st.error(f"Error during classification: {e}")
47
  else:
48
  st.warning("Please enter text to process and ensure both models are loaded.")