-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docling_no_ocr.py
More file actions
22 lines (18 loc) · 858 Bytes
/
Copy pathtest_docling_no_ocr.py
File metadata and controls
22 lines (18 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import PdfPipelineOptions, AcceleratorOptions
from docling.datamodel.base_models import InputFormat
import logging
logging.basicConfig(level=logging.INFO)
opts = PdfPipelineOptions()
opts.accelerator_options = AcceleratorOptions(num_threads=1, device="cpu")
opts.do_ocr = False
opts.images_scale = 1.0 # limit rendering size
converter = DocumentConverter(
format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=opts)}
)
print('Starting parser on 41-page PDF without OCR and smaller scale...')
try:
res = converter.convert(r'E:\vraj\Projects\powermind\data\Document-Grounded Conversational AI using RAG (1).pdf')
print('SUCCESS! Parsed pages:', len(res.document.pages))
except Exception as e:
print('FAILED:', e)