karthi311 commited on
Commit
9ff4d36
·
verified ·
1 Parent(s): 085302e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,11 +1,14 @@
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Load the summarization model (facebook/bart-large-cnn)
5
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
 
7
- # Use a smaller grammar correction model
8
- grammar_correction_pipe = pipeline("text2text-generation", model="pszemraj/grammar-synthesis-small")
9
 
10
  # Function for grammar correction
11
  def correct_grammar(user_input):
@@ -38,12 +41,12 @@ task = st.selectbox("Choose a task", ["Summarize Text", "Correct Grammar"])
38
  # Input component for text
39
  user_input = st.text_area("Enter your text here:")
40
 
41
- # Button to submit the input
42
  if st.button("Submit"):
43
  if task == "Summarize Text":
44
  output = correct_and_summarize(user_input) # Correct grammar, then summarize
45
  elif task == "Correct Grammar":
46
  output = correct_grammar(user_input) # Only correct grammar
47
 
48
- # Display the result
49
- st.text_area("Output", output, height=200)
 
1
+ # Install required packages if not already installed
2
+ !pip install streamlit transformers
3
+
4
  import streamlit as st
5
  from transformers import pipeline
6
 
7
+ # Load the summarization model
8
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
9
 
10
+ # Load the grammar correction model
11
+ grammar_correction_pipe = pipeline("text2text-generation", model="pszemraj/flan-t5-large-grammar-synthesis")
12
 
13
  # Function for grammar correction
14
  def correct_grammar(user_input):
 
41
  # Input component for text
42
  user_input = st.text_area("Enter your text here:")
43
 
44
+ # Process and display output based on selected task
45
  if st.button("Submit"):
46
  if task == "Summarize Text":
47
  output = correct_and_summarize(user_input) # Correct grammar, then summarize
48
  elif task == "Correct Grammar":
49
  output = correct_grammar(user_input) # Only correct grammar
50
 
51
+ # Display the output
52
+ st.text_area("Output", output, height=200, disabled=True)