Update app.py
Browse files
app.py
CHANGED
@@ -50,7 +50,7 @@ import pytesseract
|
|
50 |
from PIL import Image
|
51 |
@st.experimental_singleton
|
52 |
def read_pdf(file):
|
53 |
-
images=pdf2image.
|
54 |
# print(type(images))
|
55 |
# pdfReader = PdfFileReader(file)
|
56 |
# count = pdfReader.numPages
|
@@ -124,7 +124,10 @@ def main():
|
|
124 |
if st.session_state["photo"]=="done" or message:
|
125 |
#text=""
|
126 |
if uploaded_photo.type=='application/pdf':
|
127 |
-
|
|
|
|
|
|
|
128 |
#text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
129 |
st.success(text)
|
130 |
elif uploaded_photo.type != "application/image":
|
|
|
50 |
from PIL import Image
|
51 |
@st.experimental_singleton
|
52 |
def read_pdf(file):
|
53 |
+
images=pdf2image.convert_from_path(file)
|
54 |
# print(type(images))
|
55 |
# pdfReader = PdfFileReader(file)
|
56 |
# count = pdfReader.numPages
|
|
|
124 |
if st.session_state["photo"]=="done" or message:
|
125 |
#text=""
|
126 |
if uploaded_photo.type=='application/pdf':
|
127 |
+
file = uploaded_file.read() # Read the data
|
128 |
+
image_result = open(uploaded_file.name, 'wb') # creates a writable image and later we can write the decoded result
|
129 |
+
image_result.write(file)
|
130 |
+
text = read_pdf(image_result)
|
131 |
#text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
132 |
st.success(text)
|
133 |
elif uploaded_photo.type != "application/image":
|