Soumen commited on
Commit
d0ba2f9
·
1 Parent(s): f780d66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
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.convert_from_bytes(file.read())
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
- text = read_pdf(uploaded_photo)
 
 
 
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":