xavierbarbier commited on
Commit
49fdcd9
·
verified ·
1 Parent(s): fc614bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -52,9 +52,20 @@ p = pipeline(
52
  )
53
 
54
  def qa(question: str, doc: str) -> str:
55
- img = convert_from_path(doc)[0]
56
- output = p(img, question)
57
- return sorted(output, key=lambda x: x["score"], reverse=True)[0]['answer']
 
 
 
 
 
 
 
 
 
 
 
58
 
59
 
60
  demo = gr.Interface(
 
52
  )
53
 
54
  def qa(question: str, doc: str) -> str:
55
+
56
+ reader = PdfReader(doc)
57
+
58
+ text = []
59
+ for p in np.arange(0, len(reader.pages), 1):
60
+ page = reader.pages[int(p)]
61
+
62
+ # extracting text from page
63
+ text.append(page.extract_text())
64
+
65
+ text = ' '.join(text)
66
+
67
+
68
+ return text
69
 
70
 
71
  demo = gr.Interface(