Update app.py
Browse files
app.py
CHANGED
|
@@ -82,31 +82,26 @@ def bansum(text):
|
|
| 82 |
if isinstance(out, list) and out[0].get("summary_text"):
|
| 83 |
text_output = out[0]["summary_text"]
|
| 84 |
st.success(text_output)
|
| 85 |
-
|
| 86 |
-
#Summarize=True
|
| 87 |
#@st.cache
|
| 88 |
def main():
|
| 89 |
import streamlit as st
|
| 90 |
import time
|
| 91 |
-
if st.
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
with st.container():
|
| 98 |
-
message =
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
uploaded_photo = c2.file_uploader("Upload your Images/PDF",type=['jpg','png','jpeg'], on_change=change_photo_state)
|
| 107 |
-
if c3.button("PDF"):
|
| 108 |
-
uploaded_photo = c3.file_uploader("Upload your Images/PDF",type=['pdf'], on_change=change_photo_state)
|
| 109 |
-
#Summarize=True
|
| 110 |
if st.session_state["photo"]=="done" or message:
|
| 111 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
| 112 |
tet = read_pdf(uploaded_photo)
|
|
@@ -135,11 +130,12 @@ def main():
|
|
| 135 |
img = img.save("img.png")
|
| 136 |
img = cv2.imread("img.png")
|
| 137 |
st.text("Select the summarization type:")
|
| 138 |
-
|
|
|
|
| 139 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 140 |
st.subheader("সারাংশ/সারমর্ম")
|
| 141 |
bansum(text)
|
| 142 |
-
if
|
| 143 |
text=pytesseract.image_to_string(img)
|
| 144 |
st.subheader("Summarized Text")
|
| 145 |
engsum(text)
|
|
@@ -151,23 +147,24 @@ def main():
|
|
| 151 |
img = cv2.imread("img.png")
|
| 152 |
#text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
|
| 153 |
st.text("Select the summarization type:")
|
| 154 |
-
|
|
|
|
| 155 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 156 |
st.subheader("সারাংশ/সারমর্ম")
|
| 157 |
bansum(text)
|
| 158 |
-
if
|
| 159 |
text=pytesseract.image_to_string(img)
|
| 160 |
st.subheader("Summarized Text")
|
| 161 |
engsum(text)
|
| 162 |
else:
|
| 163 |
text=None
|
| 164 |
text = message
|
| 165 |
-
|
|
|
|
| 166 |
bansum(text)
|
| 167 |
-
if
|
| 168 |
engsum(text)
|
| 169 |
-
if st.checkbox("
|
| 170 |
-
Summarize=False
|
| 171 |
with st.container():
|
| 172 |
from streamlit_chat import message as st_message
|
| 173 |
from transformers import BlenderbotTokenizer
|
|
|
|
| 82 |
if isinstance(out, list) and out[0].get("summary_text"):
|
| 83 |
text_output = out[0]["summary_text"]
|
| 84 |
st.success(text_output)
|
| 85 |
+
|
|
|
|
| 86 |
#@st.cache
|
| 87 |
def main():
|
| 88 |
import streamlit as st
|
| 89 |
import time
|
| 90 |
+
if "photo" not in st.session_state:
|
| 91 |
+
st.session_state["photo"]="not done"
|
| 92 |
+
def change_photo_state():
|
| 93 |
+
st.session_state["photo"]="done"
|
| 94 |
+
c1, c2, c3 = st.columns([2,2,1])
|
| 95 |
+
if st.checkbox("Summarize from text/images/pdfs"):
|
| 96 |
with st.container():
|
| 97 |
+
message = c1.text_input("Type your text here!")
|
| 98 |
+
if c2.button("CaptureImage"):
|
| 99 |
+
camera_photo = c2.camera_input("Capture a photo to summarize: ", on_change=change_photo_state)
|
| 100 |
+
if c2.button("Stop camera"):
|
| 101 |
+
CaptureImage =False
|
| 102 |
+
if c3.button("Upload Images/PDFs"):
|
| 103 |
+
time.sleep(3)
|
| 104 |
+
uploaded_photo = c3.file_uploader("Upload your Images/PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
if st.session_state["photo"]=="done" or message:
|
| 106 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
| 107 |
tet = read_pdf(uploaded_photo)
|
|
|
|
| 130 |
img = img.save("img.png")
|
| 131 |
img = cv2.imread("img.png")
|
| 132 |
st.text("Select the summarization type:")
|
| 133 |
+
c4, c5 = st.columns([1,1])
|
| 134 |
+
if c4.button("BENGALI"):
|
| 135 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 136 |
st.subheader("সারাংশ/সারমর্ম")
|
| 137 |
bansum(text)
|
| 138 |
+
if c5.button("ENGLISH"):
|
| 139 |
text=pytesseract.image_to_string(img)
|
| 140 |
st.subheader("Summarized Text")
|
| 141 |
engsum(text)
|
|
|
|
| 147 |
img = cv2.imread("img.png")
|
| 148 |
#text = pytesseract.image_to_string(img) if st.checkbox("Bangla") else pytesseract.image_to_string(img, lang="ben")
|
| 149 |
st.text("Select the summarization type:")
|
| 150 |
+
c6, c7 = st.columns([1,1])
|
| 151 |
+
if c6.button("Bangla"):
|
| 152 |
text = pytesseract.image_to_string(img, lang="ben")
|
| 153 |
st.subheader("সারাংশ/সারমর্ম")
|
| 154 |
bansum(text)
|
| 155 |
+
if c7.button("English"):
|
| 156 |
text=pytesseract.image_to_string(img)
|
| 157 |
st.subheader("Summarized Text")
|
| 158 |
engsum(text)
|
| 159 |
else:
|
| 160 |
text=None
|
| 161 |
text = message
|
| 162 |
+
c8, c9 = st.columns([1,1])
|
| 163 |
+
if c8.button("Bangla"):
|
| 164 |
bansum(text)
|
| 165 |
+
if c9.button("English"):
|
| 166 |
engsum(text)
|
| 167 |
+
if st.checkbox("Conversate"):
|
|
|
|
| 168 |
with st.container():
|
| 169 |
from streamlit_chat import message as st_message
|
| 170 |
from transformers import BlenderbotTokenizer
|