-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
810f1c8
commit 405380f
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
from docling_core.types.doc import ImageRefMode, PictureItem, TableItem | ||
from docling.datamodel.base_models import FigureElement, InputFormat, Table | ||
from docling.datamodel.pipeline_options import PdfPipelineOptions | ||
from docling.document_converter import DocumentConverter, PdfFormatOption | ||
|
||
source = os.getenv("INPUT") | ||
|
||
|
||
IMAGE_RESOLUTION_SCALE = 2.0 | ||
|
||
pipeline_options = PdfPipelineOptions() | ||
pipeline_options.images_scale = IMAGE_RESOLUTION_SCALE | ||
pipeline_options.generate_picture_images = True | ||
|
||
converter = DocumentConverter( | ||
format_options={ | ||
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options) | ||
} | ||
) | ||
result = converter.convert(source) | ||
|
||
# TODO: send embedded images to VLM for captioning | ||
|
||
|
||
with open(os.getenv("OUTPUT"), "w") as f: | ||
f.write(result.document.export_to_markdown(image_mode=ImageRefMode.EMBEDDED)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Name: Docling-Parse PDF Document Loader | ||
Params: input: Path to input PDF file | ||
Params: output: Path to output file where the extracted markdown content should be written to. Should end with .md | ||
metadata: supported-file-type: pdf | ||
|
||
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/load.py | ||
|
||
|