SalML commited on
Commit
fc5b87f
1 Parent(s): bd077dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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 = DetrForObjectDetection.from_pretrained("microsoft/table-transformer-detection")
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 = DetrForObjectDetection.from_pretrained("microsoft/table-transformer-structure-recognition")
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