-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add EngineConfig & StrategyHandler (#211)
* fix: Add EngineConfig & StrategyHandler * fix: Configs settings
- Loading branch information
Showing
9 changed files
with
258 additions
and
153 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,47 @@ | ||
from enum import Enum | ||
|
||
from pydantic import BaseModel | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
|
||
class TextDetConfig(BaseModel): | ||
det_arch: str = "fast_base" | ||
batch_size: int = 2 | ||
assume_straight_pages: bool = True | ||
preserve_aspect_ratio: bool = True | ||
symmetric_pad: bool = True | ||
load_in_8_bit: bool = False | ||
|
||
|
||
class AutoStrategyConfig(BaseModel): | ||
auto_page_threshold: float = 0.6 | ||
auto_document_threshold: float = 0.2 | ||
|
||
|
||
class TextRecoConfig(BaseModel): | ||
reco_arch: str = "crnn_vgg16_bn" | ||
batch_size: int = 512 | ||
|
||
|
||
class DeviceEnum(str, Enum): | ||
CPU = "cpu" | ||
CUDA = "cuda" | ||
COREML = "coreml" | ||
|
||
|
||
class MegaParseConfig(BaseSettings): | ||
""" | ||
Configuration for Megaparse. | ||
""" | ||
|
||
model_config = SettingsConfigDict( | ||
env_prefix="MEGAPARSE_", | ||
env_file=(".env.local", ".env"), | ||
env_nested_delimiter="__", | ||
extra="ignore", | ||
use_enum_values=True, | ||
) | ||
text_det_config: TextDetConfig = TextDetConfig() | ||
text_reco_config: TextRecoConfig = TextRecoConfig() | ||
auto_parse_config: AutoStrategyConfig = AutoStrategyConfig() | ||
device: DeviceEnum = DeviceEnum.CPU |
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
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
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
Oops, something went wrong.