remove pydantic warning for model_

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
Michele Dolfi 2024-10-08 11:32:54 +02:00
parent 67746044a9
commit ea3f720ef5

View File

@ -1,7 +1,7 @@
from enum import Enum, auto from enum import Enum, auto
from typing import List, Literal, Optional, Union from typing import List, Literal, Optional, Union
from pydantic import BaseModel, Field from pydantic import BaseModel, ConfigDict, Field
class TableFormerMode(str, Enum): class TableFormerMode(str, Enum):
@ -30,17 +30,30 @@ class EasyOcrOptions(OcrOptions):
model_storage_directory: Optional[str] = None model_storage_directory: Optional[str] = None
download_enabled: bool = True # same default as easyocr.Reader download_enabled: bool = True # same default as easyocr.Reader
model_config = ConfigDict(
extra="forbid",
protected_namespaces=(),
)
class TesseractOcrOptions(OcrOptions): class TesseractOcrOptions(OcrOptions):
kind: Literal["tesseract"] = "tesseract" kind: Literal["tesseract"] = "tesseract"
lang: List[str] = ["fra", "deu", "spa", "eng"] lang: List[str] = ["fra", "deu", "spa", "eng"]
tesseract_cmd: str = "tesseract" tesseract_cmd: str = "tesseract"
model_config = ConfigDict(
extra="forbid",
)
class TesserOcrOptions(OcrOptions): class TesserOcrOptions(OcrOptions):
kind: Literal["tesserocr"] = "tesserocr" kind: Literal["tesserocr"] = "tesserocr"
lang: List[str] = ["fra", "deu", "spa", "eng"] lang: List[str] = ["fra", "deu", "spa", "eng"]
model_config = ConfigDict(
extra="forbid",
)
class PipelineOptions(BaseModel): class PipelineOptions(BaseModel):
do_table_structure: bool = True # True: perform table structure extraction do_table_structure: bool = True # True: perform table structure extraction