Soumen commited on
Commit
b9b4937
1 Parent(s): fda8d0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -31
app.py CHANGED
@@ -125,44 +125,42 @@ def main():
125
  #img = cv2.imread("scholarly_text.jpg")
126
  text = message
127
  if st.checkbox("Show Named Entities English/Bangla"):
128
- entity_result = entity_analyzer(text)
129
- st.json(entity_result)
130
- if st.checkbox("Show Sentiment Analysis for English"):
131
- blob = TextBlob(text)
132
- result_sentiment = blob.sentiment
133
- st.success(result_sentiment)
134
- if st.checkbox("Spell Corrections for English"):
135
- st.success(TextBlob(text).correct())
136
- if st.checkbox("Text Generation"):
137
- ok = st.button("Generate")
138
- if ok:
139
- tokenizer, model = load_models()
140
- input_ids = tokenizer(text, return_tensors='pt').input_ids
141
- st.text("Using Hugging Face Transformer, Contrastive Search ..")
142
- output = model.generate(input_ids, max_length=128)
143
- st.success(tokenizer.decode(output[0], skip_special_tokens=True))
144
- if st.checkbox("Mark here, Text Summarization for English or Bangla!"):
145
  #st.subheader("Summarize Your Text for English and Bangla Texts!")
146
  #message = st.text_area("Enter the Text","Type please ..")
147
  #st.text("Using Gensim Summarizer ..")
148
  #st.success(mess)
149
- summary_result = summarize(text)
150
- st.success(summary_result)
151
- if st.checkbox("Mark to better English Text Summarization!"):
152
  #st.title("Summarize Your Text for English only!")
153
- tokenizer = AutoTokenizer.from_pretrained('t5-base')
154
- model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True)
155
  #st.text("Using Google T5 Transformer ..")
156
- inputs = tokenizer.encode("summarize: " + text,
157
  return_tensors='pt',
158
  max_length=512,
159
  truncation=True)
160
- summary_ids = model.generate(inputs, max_length=150, min_length=80, length_penalty=5., num_beams=2)
161
- summary = tokenizer.decode(summary_ids[0])
162
- st.success(summary)
163
-
164
- st.sidebar.subheader("About App")
165
- st.sidebar.markdown("By [Soumen Sarker](https://soumen-sarker-personal-website.streamlitapp.com/)")
166
-
167
  if __name__ == '__main__':
168
- main()
 
125
  #img = cv2.imread("scholarly_text.jpg")
126
  text = message
127
  if st.checkbox("Show Named Entities English/Bangla"):
128
+ entity_result = entity_analyzer(text)
129
+ st.json(entity_result)
130
+ if st.checkbox("Show Sentiment Analysis for English"):
131
+ blob = TextBlob(text)
132
+ result_sentiment = blob.sentiment
133
+ st.success(result_sentiment)
134
+ if st.checkbox("Spell Corrections for English"):
135
+ st.success(TextBlob(text).correct())
136
+ if st.checkbox("Text Generation"):
137
+ ok = st.button("Generate")
138
+ if ok:
139
+ tokenizer, model = load_models()
140
+ input_ids = tokenizer(text, return_tensors='pt').input_ids
141
+ st.text("Using Hugging Face Transformer, Contrastive Search ..")
142
+ output = model.generate(input_ids, max_length=128)
143
+ st.success(tokenizer.decode(output[0], skip_special_tokens=True))
144
+ if st.checkbox("Mark here, Text Summarization for English or Bangla!"):
145
  #st.subheader("Summarize Your Text for English and Bangla Texts!")
146
  #message = st.text_area("Enter the Text","Type please ..")
147
  #st.text("Using Gensim Summarizer ..")
148
  #st.success(mess)
149
+ summary_result = summarize(text)
150
+ st.success(summary_result)
151
+ if st.checkbox("Mark to better English Text Summarization!"):
152
  #st.title("Summarize Your Text for English only!")
153
+ tokenizer = AutoTokenizer.from_pretrained('t5-base')
154
+ model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True)
155
  #st.text("Using Google T5 Transformer ..")
156
+ inputs = tokenizer.encode("summarize: " + text,
157
  return_tensors='pt',
158
  max_length=512,
159
  truncation=True)
160
+ summary_ids = model.generate(inputs, max_length=150, min_length=80, length_penalty=5., num_beams=2)
161
+ summary = tokenizer.decode(summary_ids[0])
162
+ st.success(summary)
163
+ st.sidebar.subheader("About App")
164
+ st.sidebar.markdown("By [Soumen Sarker](https://soumen-sarker-personal-website.streamlitapp.com/)")
 
 
165
  if __name__ == '__main__':
166
+ main()