codeteach commited on
Commit
16d8bf6
1 Parent(s): 7ac6acd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -14,7 +14,10 @@ summarizer = pipeline("summarization")
14
  def extract_text_from_pdf(pdf_file):
15
  text = ""
16
  try:
17
- document = fitz.open(stream=pdf_file.read(), filetype="pdf")
 
 
 
18
  for page_num in range(len(document)):
19
  page = document.load_page(page_num)
20
  text += page.get_text()
@@ -104,3 +107,4 @@ interface.launch()
104
 
105
 
106
 
 
 
14
  def extract_text_from_pdf(pdf_file):
15
  text = ""
16
  try:
17
+ if isinstance(pdf_file, bytes):
18
+ document = fitz.open(stream=pdf_file, filetype="pdf")
19
+ else:
20
+ document = fitz.open(stream=pdf_file.read(), filetype="pdf")
21
  for page_num in range(len(document)):
22
  page = document.load_page(page_num)
23
  text += page.get_text()
 
107
 
108
 
109
 
110
+