Soumen commited on
Commit
94c6048
·
1 Parent(s): 2c9d992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -74,6 +74,7 @@ def bansum(text):
74
  st.title("NLP APPLICATION")
75
  #@st.cache_resource(experimental_allow_widgets=True)
76
  def main():
 
77
  #global tokenizer, model
78
  #tokenizer = AutoTokenizer.from_pretrained('t5-base')
79
  #model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True)
@@ -106,28 +107,34 @@ def main():
106
  img = Image.open(uploaded_photo)
107
  img = img.save("img.png")
108
  img = cv2.imread("img.png")
 
109
  if st.button("Content Type: Bangla"):
110
  text = pytesseract.image_to_string(img, lang="ben")
 
111
  if st.button("Content Type: English"):
112
  text=pytesseract.image_to_string(img)
 
113
  #st.success(text)
114
  elif camera_photo:
115
  img = Image.open(camera_photo)
116
  img = img.save("img.png")
117
  img = cv2.imread("img.png")
118
  #text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
 
119
  if st.button("Content Type: Bangla"):
120
  text = pytesseract.image_to_string(img, lang="ben")
 
121
  if st.button("Content Type: English"):
122
  text=pytesseract.image_to_string(img)
 
123
  st.success(text)
124
  elif uploaded_photo==None and camera_photo==None:
125
  text = message
126
 
127
  if st.checkbox("Mark for Text Summarization"):
128
- if st.button("Summarize Bangla Texts"):
129
  bansum(text)
130
- if st.button("Summarize English Texts"):
131
  engsum(text)
132
 
133
  if st.checkbox("English Text Generation"):
@@ -141,7 +148,6 @@ def main():
141
  if isinstance(out, list) and out[0].get("generated_text"):
142
  text_output = out[0]["generated_text"]
143
  st.success(text_output)
144
- if st.button("Refresh"):
145
- st.cache_data.clear()
146
  if __name__ == '__main__':
147
  main()
 
74
  st.title("NLP APPLICATION")
75
  #@st.cache_resource(experimental_allow_widgets=True)
76
  def main():
77
+ s=0
78
  #global tokenizer, model
79
  #tokenizer = AutoTokenizer.from_pretrained('t5-base')
80
  #model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True)
 
107
  img = Image.open(uploaded_photo)
108
  img = img.save("img.png")
109
  img = cv2.imread("img.png")
110
+ st.text("Press the content type:")
111
  if st.button("Content Type: Bangla"):
112
  text = pytesseract.image_to_string(img, lang="ben")
113
+ s=1
114
  if st.button("Content Type: English"):
115
  text=pytesseract.image_to_string(img)
116
+ s=0
117
  #st.success(text)
118
  elif camera_photo:
119
  img = Image.open(camera_photo)
120
  img = img.save("img.png")
121
  img = cv2.imread("img.png")
122
  #text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
123
+ st.text("Press the content type:")
124
  if st.button("Content Type: Bangla"):
125
  text = pytesseract.image_to_string(img, lang="ben")
126
+ s=1
127
  if st.button("Content Type: English"):
128
  text=pytesseract.image_to_string(img)
129
+ s=0
130
  st.success(text)
131
  elif uploaded_photo==None and camera_photo==None:
132
  text = message
133
 
134
  if st.checkbox("Mark for Text Summarization"):
135
+ if s==1:
136
  bansum(text)
137
+ else:
138
  engsum(text)
139
 
140
  if st.checkbox("English Text Generation"):
 
148
  if isinstance(out, list) and out[0].get("generated_text"):
149
  text_output = out[0]["generated_text"]
150
  st.success(text_output)
151
+
 
152
  if __name__ == '__main__':
153
  main()