mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-26 03:55:00 +00:00
need to fix ruff linter
Signed-off-by: Peter Staar <taa@zurich.ibm.com>
This commit is contained in:
parent
32ad65cb9f
commit
76501331d2
@ -8,8 +8,8 @@ from docling.backend.abstract_backend import AbstractDocumentBackend
|
||||
from docling.datamodel.base_models import InputFormat
|
||||
from docling.datamodel.document import InputDocument
|
||||
|
||||
class WavDocumentBackend(AbstractDocumentBackend):
|
||||
|
||||
class WavDocumentBackend(AbstractDocumentBackend):
|
||||
def __init__(self, in_doc: "InputDocument", path_or_stream: Union[BytesIO, Path]):
|
||||
super().__init__(in_doc, path_or_stream)
|
||||
|
||||
@ -29,4 +29,3 @@ class WavDocumentBackend(AbstractDocumentBackend):
|
||||
@classmethod
|
||||
def supported_formats(cls) -> set[InputFormat]:
|
||||
return {InputFormat.WAV}
|
||||
|
||||
|
@ -579,7 +579,6 @@ def convert( # noqa: C901
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
_log.error(f"Did not find the correct pipeline: {pipeline}")
|
||||
|
||||
if artifacts_path is not None:
|
||||
|
@ -51,6 +51,7 @@ class InputFormat(str, Enum):
|
||||
# Audio
|
||||
WAV = "wav"
|
||||
|
||||
|
||||
class OutputFormat(str, Enum):
|
||||
MARKDOWN = "md"
|
||||
JSON = "json"
|
||||
@ -105,7 +106,6 @@ FormatToMimeType: Dict[InputFormat, List[str]] = {
|
||||
],
|
||||
InputFormat.XML_USPTO: ["application/xml", "text/plain"],
|
||||
InputFormat.JSON_DOCLING: ["application/json"],
|
||||
|
||||
# Audio
|
||||
InputFormat.WAV: ["audio/wav", "audio/x-wav"],
|
||||
}
|
||||
@ -165,6 +165,7 @@ class LayoutPrediction(BaseModel):
|
||||
class VlmPrediction(BaseModel):
|
||||
text: str = ""
|
||||
|
||||
|
||||
class AsrPrediction(BaseModel):
|
||||
text: str = ""
|
||||
|
||||
|
@ -257,10 +257,12 @@ class BaseVlmOptions(BaseModel):
|
||||
kind: str
|
||||
prompt: str
|
||||
|
||||
|
||||
class BaseAsrOptions(BaseModel):
|
||||
kind: str
|
||||
prompt: str
|
||||
|
||||
|
||||
class ResponseFormat(str, Enum):
|
||||
DOCTAGS = "doctags"
|
||||
MARKDOWN = "markdown"
|
||||
@ -274,6 +276,7 @@ class InferenceFramework(str, Enum):
|
||||
# Audio
|
||||
ASR_NEMO = "asr_nemo"
|
||||
|
||||
|
||||
class HuggingFaceVlmOptions(BaseVlmOptions):
|
||||
kind: Literal["hf_model_options"] = "hf_model_options"
|
||||
|
||||
@ -289,6 +292,7 @@ class HuggingFaceVlmOptions(BaseVlmOptions):
|
||||
def repo_cache_folder(self) -> str:
|
||||
return self.repo_id.replace("/", "--")
|
||||
|
||||
|
||||
class HuggingFaceAsrOptions(BaseVlmOptions):
|
||||
kind: Literal["hf_model_options"] = "hf_model_options"
|
||||
|
||||
@ -304,6 +308,7 @@ class HuggingFaceAsrOptions(BaseVlmOptions):
|
||||
def repo_cache_folder(self) -> str:
|
||||
return self.repo_id.replace("/", "--")
|
||||
|
||||
|
||||
class ApiVlmOptions(BaseVlmOptions):
|
||||
kind: Literal["api_model_options"] = "api_model_options"
|
||||
|
||||
@ -415,10 +420,10 @@ class VlmPipelineOptions(PaginatedPipelineOptions):
|
||||
smoldocling_vlm_conversion_options
|
||||
)
|
||||
|
||||
|
||||
class AsrPipelineOptions(PaginatedPipelineOptions):
|
||||
asr_options: Union[HuggingFaceAsrOptions] = (
|
||||
asr_nemo_conversion_options
|
||||
)
|
||||
asr_options: Union[HuggingFaceAsrOptions] = asr_nemo_conversion_options
|
||||
|
||||
|
||||
class PdfPipelineOptions(PaginatedPipelineOptions):
|
||||
"""Options for the PDF pipeline."""
|
||||
|
@ -19,9 +19,9 @@ from docling.backend.md_backend import MarkdownDocumentBackend
|
||||
from docling.backend.msexcel_backend import MsExcelDocumentBackend
|
||||
from docling.backend.mspowerpoint_backend import MsPowerpointDocumentBackend
|
||||
from docling.backend.msword_backend import MsWordDocumentBackend
|
||||
from docling.backend.wav_backend import WavDocumentBackend
|
||||
from docling.backend.xml.jats_backend import JatsDocumentBackend
|
||||
from docling.backend.xml.uspto_backend import PatentUsptoDocumentBackend
|
||||
from docling.backend.wav_backend import WavDocumentBackend
|
||||
from docling.datamodel.base_models import (
|
||||
ConversionStatus,
|
||||
DoclingComponentType,
|
||||
@ -34,7 +34,7 @@ from docling.datamodel.document import (
|
||||
InputDocument,
|
||||
_DocumentConversionInput,
|
||||
)
|
||||
from docling.datamodel.pipeline_options import PipelineOptions, AsrPipelineOptions
|
||||
from docling.datamodel.pipeline_options import AsrPipelineOptions, PipelineOptions
|
||||
from docling.datamodel.settings import (
|
||||
DEFAULT_PAGE_RANGE,
|
||||
DocumentLimits,
|
||||
@ -42,10 +42,10 @@ from docling.datamodel.settings import (
|
||||
settings,
|
||||
)
|
||||
from docling.exceptions import ConversionError
|
||||
from docling.pipeline.asr_pipeline import AsrPipeline
|
||||
from docling.pipeline.base_pipeline import BasePipeline
|
||||
from docling.pipeline.simple_pipeline import SimplePipeline
|
||||
from docling.pipeline.standard_pdf_pipeline import StandardPdfPipeline
|
||||
from docling.pipeline.asr_pipeline import AsrPipeline
|
||||
from docling.utils.utils import chunkify
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
@ -119,9 +119,11 @@ class PdfFormatOption(FormatOption):
|
||||
pipeline_cls: Type = StandardPdfPipeline
|
||||
backend: Type[AbstractDocumentBackend] = DoclingParseV4DocumentBackend
|
||||
|
||||
|
||||
class AsrFormatOption(FormatOption):
|
||||
pipeline_cls: Type = AsrPipeline
|
||||
|
||||
|
||||
def _get_default_option(format: InputFormat) -> FormatOption:
|
||||
format_to_default_options = {
|
||||
InputFormat.CSV: FormatOption(
|
||||
|
@ -10,13 +10,13 @@ from docling.datamodel.pipeline_options import (
|
||||
AcceleratorOptions,
|
||||
HuggingFaceAsrOptions,
|
||||
)
|
||||
|
||||
from docling.models.base_model import BasePageModel
|
||||
from docling.utils.accelerator_utils import decide_device
|
||||
from docling.utils.profiling import TimeRecorder
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AsrNemoModel(BasePageModel):
|
||||
def __init__(
|
||||
self,
|
||||
@ -45,7 +45,6 @@ class AsrNemoModel(BasePageModel):
|
||||
elif (artifacts_path / repo_cache_folder).exists():
|
||||
artifacts_path = artifacts_path / repo_cache_folder
|
||||
|
||||
self.model = nemo_asr.models.ASRModel.from_pretrained("nvidia/parakeet-tdt-0.6b-v2")
|
||||
|
||||
|
||||
|
||||
self.model = nemo_asr.models.ASRModel.from_pretrained(
|
||||
"nvidia/parakeet-tdt-0.6b-v2"
|
||||
)
|
||||
|
@ -9,18 +9,16 @@ from docling.backend.abstract_backend import (
|
||||
)
|
||||
from docling.datamodel.base_models import ConversionStatus
|
||||
from docling.datamodel.document import ConversionResult
|
||||
from docling.datamodel.pipeline_options import PipelineOptions
|
||||
from docling.pipeline.base_pipeline import BasePipeline
|
||||
from docling.utils.profiling import ProfilingScope, TimeRecorder
|
||||
|
||||
from docling.datamodel.pipeline_options import (
|
||||
AsrPipelineOptions,
|
||||
HuggingFaceAsrOptions,
|
||||
InferenceFramework,
|
||||
PipelineOptions,
|
||||
ResponseFormat,
|
||||
AsrPipelineOptions,
|
||||
)
|
||||
|
||||
from docling.models.hf_asr_models.asr_nemo import AsrNemoModel
|
||||
from docling.pipeline.base_pipeline import BasePipeline
|
||||
from docling.utils.profiling import ProfilingScope, TimeRecorder
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
@ -59,7 +57,7 @@ class AsrPipeline(BasePipeline):
|
||||
_log.error(f"{asr_options.inference_framework} is not supported")
|
||||
|
||||
else:
|
||||
_log.error(f"ASR is not supported")
|
||||
_log.error("ASR is not supported")
|
||||
|
||||
def _build_document(self, conv_res: ConversionResult) -> ConversionResult:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user