Skip to content
Open
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: 3 additions & 1 deletion src/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import random
import io
import copy

import torch
from torchvision import transforms
Expand Down Expand Up @@ -249,14 +250,15 @@ def outputs_to_objects(outputs, img_size, class_idx2name):

return objects

def objects_to_crops(img, tokens, objects, class_thresholds, padding=10):
def objects_to_crops(img, tokens_original, objects, class_thresholds, padding=10):
"""
Process the bounding boxes produced by the table detection model into
cropped table images and cropped tokens.
"""

table_crops = []
for obj in objects:
tokens = copy.deepcopy(tokens_original)
if obj['score'] < class_thresholds[obj['label']]:
continue

Expand Down