Update app.py
Browse files
app.py
CHANGED
@@ -80,11 +80,10 @@ def main():
|
|
80 |
st.session_state["photo"]="done"
|
81 |
message = st.text_input("Type your text here!")
|
82 |
uploaded_photo = st.sidebar.file_uploader("Upload your Images/PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
83 |
-
camera_photo = st.sidebar.camera_input("
|
84 |
if "photo" not in st.session_state:
|
85 |
st.session_state["photo"]="not done"
|
86 |
if st.session_state["photo"]=="done" or message:
|
87 |
-
text=" "
|
88 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
89 |
#file = uploaded_photo.read() # Read the data
|
90 |
#image_result = open(uploaded_photo.name, 'wb') # creates a writable image and later we can write the decoded result
|
@@ -93,8 +92,10 @@ def main():
|
|
93 |
#tet = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
94 |
values = st.slider('Select a approximate number of lines to see and summarize',value=[0, len(tet)//(7*100)])
|
95 |
text = tet[values[0]*7*10:values[1]*7*10] if values[0]!=len(tet)//(7*10) else tet[len(tet)//(7*100):]
|
|
|
|
|
96 |
engsum(text)
|
97 |
-
|
98 |
img = Image.open(uploaded_photo)
|
99 |
img = img.save("img.png")
|
100 |
img = cv2.imread("img.png")
|
@@ -106,7 +107,7 @@ def main():
|
|
106 |
text=pytesseract.image_to_string(img)
|
107 |
engsum(text)
|
108 |
#st.success(text)
|
109 |
-
|
110 |
img = Image.open(camera_photo)
|
111 |
img = img.save("img.png")
|
112 |
img = cv2.imread("img.png")
|
@@ -118,7 +119,7 @@ def main():
|
|
118 |
if st.button("English"):
|
119 |
text=pytesseract.image_to_string(img)
|
120 |
engsum(text)
|
121 |
-
|
122 |
text = message
|
123 |
if st.button("Bangla"):
|
124 |
bansum(text)
|
|
|
80 |
st.session_state["photo"]="done"
|
81 |
message = st.text_input("Type your text here!")
|
82 |
uploaded_photo = st.sidebar.file_uploader("Upload your Images/PDF",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
83 |
+
camera_photo = st.sidebar.camera_input("Capture a photo to summarize: ", on_change=change_photo_state)
|
84 |
if "photo" not in st.session_state:
|
85 |
st.session_state["photo"]="not done"
|
86 |
if st.session_state["photo"]=="done" or message:
|
|
|
87 |
if uploaded_photo and uploaded_photo.type=='application/pdf':
|
88 |
#file = uploaded_photo.read() # Read the data
|
89 |
#image_result = open(uploaded_photo.name, 'wb') # creates a writable image and later we can write the decoded result
|
|
|
92 |
#tet = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
93 |
values = st.slider('Select a approximate number of lines to see and summarize',value=[0, len(tet)//(7*100)])
|
94 |
text = tet[values[0]*7*10:values[1]*7*10] if values[0]!=len(tet)//(7*10) else tet[len(tet)//(7*100):]
|
95 |
+
if st.checkbox("Show selected text from the pdf:")
|
96 |
+
st.success(text)
|
97 |
engsum(text)
|
98 |
+
if uploaded_photo:
|
99 |
img = Image.open(uploaded_photo)
|
100 |
img = img.save("img.png")
|
101 |
img = cv2.imread("img.png")
|
|
|
107 |
text=pytesseract.image_to_string(img)
|
108 |
engsum(text)
|
109 |
#st.success(text)
|
110 |
+
if camera_photo:
|
111 |
img = Image.open(camera_photo)
|
112 |
img = img.save("img.png")
|
113 |
img = cv2.imread("img.png")
|
|
|
119 |
if st.button("English"):
|
120 |
text=pytesseract.image_to_string(img)
|
121 |
engsum(text)
|
122 |
+
if message:
|
123 |
text = message
|
124 |
if st.button("Bangla"):
|
125 |
bansum(text)
|