Not working on perfect tables

#2
by Resi - opened

How is it possble, that if I insert this perfectly cropped out table:

perfect_table.png

I get this bad result:

image.png

But if there is still a bit of uncropped text like in:
perfect_table_inkltext.png

I get much, much better results:

image.png

I need to be able to work with perfect cropped out tables, because I have a good DETR model for extracting these...
Used Code:
from transformers import TableTransformerForObjectDetection
model = TableTransformerForObjectDetection.from_pretrained("microsoft/table-transformer-structure-recognition")

def cell_detection(file_path):

image = Image.open(file_path).convert("RGB")
print()
width, height = image.size
image.resize((int(width*0.5), int(height*0.5)))


encoding = feature_extractor(image, return_tensors="pt")
encoding.keys()

with torch.no_grad():
  outputs = model(**encoding)


target_sizes = [image.size[::-1]]
results = feature_extractor.post_process_object_detection(outputs, threshold=0.6, target_sizes=target_sizes)[0]
plot_results(image, results['scores'], results['labels'], results['boxes'])
model.config.id2label

file_path = r"C:\Users\blur\Coding\blur\Segmentation\test_images\perfect_table_inkltext.png"
#file_path = r"C:\Users\blur\Coding\blur\Segmentation\test_images\perfect_table.png"
#file_path = r"C:\Users\blur\Coding\blur\Segmentation\test_images\test_kaggle.png"
cell_detection(file_path)

Sign up or log in to comment