Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying document conversion settings #48

Merged
merged 20 commits into from
Dec 13, 2022

Conversation

cau-git
Copy link
Contributor

@cau-git cau-git commented Nov 11, 2022

  • Establish simplified pydantic models to encapsulate conversion settings

Note: Nothing yet functional.

@cau-git
Copy link
Contributor Author

cau-git commented Nov 15, 2022

Some usage examples below.

Case 1: Just enable OCR

import deepsearch as ds
...
api = ds.CpsApi(client)

conv_settings = ConversionSettings.from_defaults(api)
conv_settings.ocr.enabled = True

...
documents = ds.convert_documents(
    api=api,
    proj_key=proj,
    source_path="../data/samples/2206.01062.pdf",
    conversion_settings=conv_settings
)           

Case 2: Enable OCR, and pick a backend

import deepsearch as ds
...
api = ds.CpsApi(client)

conv_settings = ConversionSettings.from_defaults(api)
conv_settings.ocr.enabled = True
conv_settings.ocr.backend = "paddle-ocr" # one of: OCRSettings.get_backends(api)

...
documents = ds.convert_documents(
    api=api,
    proj_key=proj,
    source_path="../data/samples/2206.01062.pdf",
    conversion_settings=conv_settings
)           

Case 3: Just disable table structure model on pipeline

import deepsearch as ds
...
api = ds.CpsApi(client)

conv_settings = ConversionSettings.from_defaults(api)
conv_settings.pipeline.tables = None

...
documents = ds.convert_documents(
    api=api,
    proj_key=proj,
    source_path="../data/samples/2206.01062.pdf",
    conversion_settings=conv_settings
)           

Case 4: Pick project model for table-structure on pipeline

import deepsearch as ds
...
api = ds.CpsApi(client)

conv_settings = ConversionSettings.from_defaults(api)

project_models = ProjectConversionModel.get_models(api, proj_key)

for pm in project_models:
   if pm.name == "my-ts-model-test-1": # basic example: match by name
     conv_settings.pipeline.tables = pm

...
documents = ds.convert_documents(
    api=api,
    proj_key=proj,
    source_path="../data/samples/2206.01062.pdf",
    conversion_settings=conv_settings
)           

@cau-git cau-git marked this pull request as ready for review November 28, 2022 15:50
cau-git and others added 5 commits November 29, 2022 10:41
Signed-off-by: cau-git <60343111+cau-git@users.noreply.github.com>
Signed-off-by: cau-git <60343111+cau-git@users.noreply.github.com>
Signed-off-by: cau-git <60343111+cau-git@users.noreply.github.com>
Signed-off-by: Christoph Auer <CAU@zurich.ibm.com>
Copy link
Contributor Author

@cau-git cau-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up documentation

cau-git and others added 6 commits November 29, 2022 15:43
Signed-off-by: Christoph Auer <CAU@zurich.ibm.com>
Signed-off-by: Christoph Auer <CAU@zurich.ibm.com>
Signed-off-by: cau-git <60343111+cau-git@users.noreply.github.com>
@cau-git cau-git merged commit ee59123 into main Dec 13, 2022
@cau-git cau-git deleted the cau/add-conversion-settings branch December 13, 2022 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants