Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table transformer crop issue #174

Open
tzktz opened this issue Mar 29, 2024 · 1 comment
Open

Table transformer crop issue #174

tzktz opened this issue Mar 29, 2024 · 1 comment

Comments

@tzktz
Copy link

tzktz commented Mar 29, 2024

below table detection exactly crops the table.. but i need to some gap in right and left side... because when we pass the table crop image to ocr edges values were mismatche...
download

How to adjust resize value.. i have set max resize into 800

class MaxResize(object):
    def __init__(self, max_size=800):
        self.max_size = max_size

    def __call__(self, image):
        width, height = image.size
        current_max_size = max(width, height)
        scale = self.max_size / current_max_size
        resized_image = image.resize((int(round(scale*width)), int(round(scale*height))))

        return resized_image

detection_transform = transforms.Compose([
    MaxResize(800),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

@bsmock @msftgits @themanojkumar @NielsRogge

@abielr
Copy link

abielr commented Apr 10, 2024

@tzktz, instead of looking into the MaxResize class, what you need to do is take the detected table and then expand the detected bounding box when you crop the table. See the objects_to_crops function as an example, it has a padding argument that you can use to crop out the table with additional space around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants