Update app/parsers/ocr.py
Browse files- app/parsers/ocr.py +6 -10
app/parsers/ocr.py
CHANGED
|
@@ -2,14 +2,10 @@ from pdf2image import convert_from_bytes
|
|
| 2 |
import pytesseract
|
| 3 |
from typing import List, Dict
|
| 4 |
|
| 5 |
-
|
| 6 |
-
# HF Spaces: packages.txt で tesseract-ocr と tesseract-ocr-jpn, poppler-utils をインストールしてください。
|
| 7 |
-
|
| 8 |
-
|
| 9 |
def ocr_image_pages(pdf_bytes: bytes) -> List[Dict]:
|
| 10 |
-
images = convert_from_bytes(pdf_bytes, dpi=300)
|
| 11 |
-
results = []
|
| 12 |
-
for img in images:
|
| 13 |
-
text = pytesseract.image_to_string(img, lang="jpn+eng")
|
| 14 |
-
results.append({"text": text})
|
| 15 |
-
return results
|
|
|
|
| 2 |
import pytesseract
|
| 3 |
from typing import List, Dict
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
def ocr_image_pages(pdf_bytes: bytes) -> List[Dict]:
|
| 6 |
+
images = convert_from_bytes(pdf_bytes, dpi=300)
|
| 7 |
+
results = []
|
| 8 |
+
for img in images:
|
| 9 |
+
text = pytesseract.image_to_string(img, lang="jpn+eng")
|
| 10 |
+
results.append({"text": text})
|
| 11 |
+
return results
|