Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,9 @@ import cv2
|
|
15 |
import numpy as np
|
16 |
# from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
17 |
# from cv2 import dnn_superres
|
18 |
-
from transformers import DetrFeatureExtractor
|
19 |
-
from transformers import DetrForObjectDetection
|
|
|
20 |
import torch
|
21 |
import asyncio
|
22 |
# pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
@@ -140,7 +141,7 @@ def table_detector(image, THRESHOLD_PROBA):
|
|
140 |
feature_extractor = DetrFeatureExtractor(do_resize=True, size=800, max_size=800)
|
141 |
encoding = feature_extractor(image, return_tensors="pt")
|
142 |
|
143 |
-
model =
|
144 |
|
145 |
with torch.no_grad():
|
146 |
outputs = model(**encoding)
|
@@ -163,7 +164,7 @@ def table_struct_recog(image, THRESHOLD_PROBA):
|
|
163 |
feature_extractor = DetrFeatureExtractor(do_resize=True, size=1000, max_size=1000)
|
164 |
encoding = feature_extractor(image, return_tensors="pt")
|
165 |
|
166 |
-
model =
|
167 |
with torch.no_grad():
|
168 |
outputs = model(**encoding)
|
169 |
|
|
|
15 |
import numpy as np
|
16 |
# from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
17 |
# from cv2 import dnn_superres
|
18 |
+
#from transformers import DetrFeatureExtractor
|
19 |
+
#from transformers import DetrForObjectDetection
|
20 |
+
from transformers import TableTransformerForObjectDetection
|
21 |
import torch
|
22 |
import asyncio
|
23 |
# pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
|
|
141 |
feature_extractor = DetrFeatureExtractor(do_resize=True, size=800, max_size=800)
|
142 |
encoding = feature_extractor(image, return_tensors="pt")
|
143 |
|
144 |
+
model = TableTransformerForObjectDetection.from_pretrained("microsoft/table-transformer-detection")
|
145 |
|
146 |
with torch.no_grad():
|
147 |
outputs = model(**encoding)
|
|
|
164 |
feature_extractor = DetrFeatureExtractor(do_resize=True, size=1000, max_size=1000)
|
165 |
encoding = feature_extractor(image, return_tensors="pt")
|
166 |
|
167 |
+
model = TableTransformerForObjectDetection.from_pretrained("microsoft/table-transformer-structure-recognition")
|
168 |
with torch.no_grad():
|
169 |
outputs = model(**encoding)
|
170 |
|