Spaces:
Running on Zero
Running on Zero
Upload pipeline.py with huggingface_hub
Browse files- pipeline.py +6 -1
pipeline.py
CHANGED
|
@@ -152,7 +152,12 @@ class PageOCR:
|
|
| 152 |
"""PDF -> list of page texts."""
|
| 153 |
pymupdf = importlib.import_module("pymupdf")
|
| 154 |
doc = pymupdf.open(path)
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
out = []
|
| 157 |
for i in rng:
|
| 158 |
pix = doc[i].get_pixmap(dpi=dpi)
|
|
|
|
| 152 |
"""PDF -> list of page texts."""
|
| 153 |
pymupdf = importlib.import_module("pymupdf")
|
| 154 |
doc = pymupdf.open(path)
|
| 155 |
+
if pages is None:
|
| 156 |
+
rng = range(doc.page_count)
|
| 157 |
+
else:
|
| 158 |
+
# Clamp to the document: asking for 3 pages of a 1-page PDF
|
| 159 |
+
# must not IndexError.
|
| 160 |
+
rng = [p for p in pages if 0 <= p < doc.page_count]
|
| 161 |
out = []
|
| 162 |
for i in rng:
|
| 163 |
pix = doc[i].get_pixmap(dpi=dpi)
|