Update app.py
Browse files
app.py
CHANGED
@@ -120,6 +120,9 @@ def main():
|
|
120 |
message = st.text_input("Type your text here!")
|
121 |
camera_photo = st.camera_input("Take a photo, Containing English or Bangla texts", on_change=change_photo_state)
|
122 |
uploaded_photo = st.file_uploader("Upload Bangla or English Image/ English PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
|
|
|
|
|
|
123 |
if "photo" not in st.session_state:
|
124 |
st.session_state["photo"]="not done"
|
125 |
if st.session_state["photo"]=="done" or message:
|
@@ -128,9 +131,12 @@ def main():
|
|
128 |
#file = uploaded_photo.read() # Read the data
|
129 |
#image_result = open(uploaded_photo.name, 'wb') # creates a writable image and later we can write the decoded result
|
130 |
#image_result.write(file)
|
131 |
-
|
132 |
-
|
133 |
-
st.
|
|
|
|
|
|
|
134 |
elif uploaded_photo.type != "application/image":
|
135 |
img = Image.open(uploaded_photo)
|
136 |
img = img.save("img.png")
|
@@ -195,10 +201,6 @@ def main():
|
|
195 |
summary_ids = model.generate(inputs, max_length=150, min_length=80, length_penalty=5., num_beams=2)
|
196 |
summary = tokenizer.decode(summary_ids[0])
|
197 |
st.success(summary)
|
198 |
-
# Title
|
199 |
-
if st.button("REFRESH"):
|
200 |
-
st.experimental_rerun()
|
201 |
-
|
202 |
st.sidebar.subheader("About App")
|
203 |
st.sidebar.markdown("By [Soumen Sarker](https://soumen-sarker-personal-website.streamlitapp.com/)")
|
204 |
if __name__ == '__main__':
|
|
|
120 |
message = st.text_input("Type your text here!")
|
121 |
camera_photo = st.camera_input("Take a photo, Containing English or Bangla texts", on_change=change_photo_state)
|
122 |
uploaded_photo = st.file_uploader("Upload Bangla or English Image/ English PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
123 |
+
if st.button("REFRESH"):
|
124 |
+
st.experimental_rerun()
|
125 |
+
|
126 |
if "photo" not in st.session_state:
|
127 |
st.session_state["photo"]="not done"
|
128 |
if st.session_state["photo"]=="done" or message:
|
|
|
131 |
#file = uploaded_photo.read() # Read the data
|
132 |
#image_result = open(uploaded_photo.name, 'wb') # creates a writable image and later we can write the decoded result
|
133 |
#image_result.write(file)
|
134 |
+
tet = read_pdf(uploaded_photo)
|
135 |
+
tet = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
136 |
+
values = st.slider('Select a approximate number of words to summarize', 0, 1000, (100, 775))
|
137 |
+
text = tet[:values*5]
|
138 |
+
st.success(text)
|
139 |
+
|
140 |
elif uploaded_photo.type != "application/image":
|
141 |
img = Image.open(uploaded_photo)
|
142 |
img = img.save("img.png")
|
|
|
201 |
summary_ids = model.generate(inputs, max_length=150, min_length=80, length_penalty=5., num_beams=2)
|
202 |
summary = tokenizer.decode(summary_ids[0])
|
203 |
st.success(summary)
|
|
|
|
|
|
|
|
|
204 |
st.sidebar.subheader("About App")
|
205 |
st.sidebar.markdown("By [Soumen Sarker](https://soumen-sarker-personal-website.streamlitapp.com/)")
|
206 |
if __name__ == '__main__':
|