Spaces:
Runtime error
Runtime error
Witold Wydmański
commited on
Commit
·
6b6b8dc
1
Parent(s):
21e7816
fix: save all pages instead of last only
Browse files
app.py
CHANGED
|
@@ -12,11 +12,13 @@ def pdf_to_image(pdf_file, path, progress):
|
|
| 12 |
# Convert the PDF to a PNG image using pdf2image
|
| 13 |
doc = fitz.open(pdf_file.name) # open document
|
| 14 |
fnames = []
|
|
|
|
| 15 |
for page in progress.tqdm(doc, desc="Converting PDF to image"):
|
| 16 |
pix = page.get_pixmap()
|
| 17 |
-
output = f"{path}/page.png"
|
| 18 |
pix.save(output)
|
| 19 |
fnames.append(output)
|
|
|
|
| 20 |
return fnames
|
| 21 |
|
| 22 |
def tesseract_ocr(image, progress=gr.Progress()):
|
|
|
|
| 12 |
# Convert the PDF to a PNG image using pdf2image
|
| 13 |
doc = fitz.open(pdf_file.name) # open document
|
| 14 |
fnames = []
|
| 15 |
+
idx = 1
|
| 16 |
for page in progress.tqdm(doc, desc="Converting PDF to image"):
|
| 17 |
pix = page.get_pixmap()
|
| 18 |
+
output = f"{path}/page-{idx}.png"
|
| 19 |
pix.save(output)
|
| 20 |
fnames.append(output)
|
| 21 |
+
idx += 1
|
| 22 |
return fnames
|
| 23 |
|
| 24 |
def tesseract_ocr(image, progress=gr.Progress()):
|