Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.5-dev0

* feat: parametrize edge config for `DetrImageProcessor` with env variables

## 1.0.4

* feat: use singleton instead of `global` to store shared variables
Expand Down
2 changes: 1 addition & 1 deletion unstructured_inference/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.4" # pragma: no cover
__version__ = "1.0.5-dev0" # pragma: no cover
10 changes: 10 additions & 0 deletions unstructured_inference/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,15 @@ def ELEMENTS_V_PADDING_COEF(self) -> float:
"""Same as ELEMENTS_H_PADDING_COEF but the vertical extension."""
return self._get_float("ELEMENTS_V_PADDING_COEF", 0.3)

@property
def IMG_PROCESSOR_LONGEST_EDGE(self) -> int:
"""configuration for DetrImageProcessor to scale images"""
return self._get_int("IMG_PROCESSOR_LONGEST_EDGE", 1333)

@property
def IMG_PROCESSOR_SHORTEST_EDGE(self) -> int:
"""configuration for DetrImageProcessor to scale images"""
return self._get_int("IMG_PROCESSOR_SHORTEST_EDGE", 800)


inference_config = InferenceConfig()
4 changes: 2 additions & 2 deletions unstructured_inference/models/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def initialize(
self.feature_extractor = DetrImageProcessor.from_pretrained(model)
# value not set in the configuration and needed for newer models
# https://huggingface.co/microsoft/table-transformer-structure-recognition-v1.1-all/discussions/1
self.feature_extractor.size["shortest_edge"] = 800
self.feature_extractor.size["longest_edge"] = 1333
self.feature_extractor.size["shortest_edge"] = inference_config.IMG_PROCESSOR_SHORTEST_EDGE
self.feature_extractor.size["longest_edge"] = inference_config.IMG_PROCESSOR_LONGEST_EDGE

try:
logger.info("Loading the table structure model ...")
Expand Down
Loading