Skip to content

Commit

Permalink
Dissable tatr loading warning (#365)
Browse files Browse the repository at this point in the history
There should be no warning about some weights not being loaded when table-transformer is used
Unstructured-IO/unstructured#3288
  • Loading branch information
plutasnyy authored Jul 8, 2024
1 parent 939fd39 commit 4662c4f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.7.37-dev0
## 0.7.37-dev1

* refactor: remove layout analysis related code
* enhancement: Hide warning about table transformer weights not being loaded

## 0.7.36

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__ = "0.7.37-dev0" # pragma: no cover
__version__ = "0.7.37-dev1" # pragma: no cover
5 changes: 4 additions & 1 deletion unstructured_inference/models/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import torch
from PIL import Image as PILImage
from transformers import DetrImageProcessor, TableTransformerForObjectDetection
from transformers import DetrImageProcessor, TableTransformerForObjectDetection, logging
from transformers.models.table_transformer.modeling_table_transformer import (
TableTransformerObjectDetectionOutput,
)
Expand Down Expand Up @@ -65,7 +65,10 @@ def initialize(

try:
logger.info("Loading the table structure model ...")
cached_current_verbosity = logging.get_verbosity()
logging.set_verbosity_error()
self.model = TableTransformerForObjectDetection.from_pretrained(model)
logging.set_verbosity(cached_current_verbosity)
self.model.eval()

except EnvironmentError:
Expand Down

0 comments on commit 4662c4f

Please sign in to comment.