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

Update create_grid_input.py #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LUCIFERX92
Copy link

TypeError in create_grid_input.py

Description of the Issue

When running the script, the following error occurs:

File "/Users/i_manav.gupta/VGT_V4/VGT/object_detection/create_grid_input.py", line 215, in <module>
    save_pkl_file(grid, args.output, f"page_{page}", page, args.model)
TypeError: save_pkl_file() takes from 3 to 4 positional arguments but 5 were given

This error suggests that the save_pkl_file() function is being called with more arguments than it can accept.

Proposed Solution

Update the save_pkl_file() function in VGT/object_detection/create_grid_input.py to accept the correct number of arguments:

def save_pkl_file(grid, output_dir, filename, model):
    os.makedirs(output_dir, exist_ok=True)
    if model == 'doclaynet':
        with open(os.path.join(output_dir, f"{filename}.pkl"), 'wb') as f:
            pickle.dump(grid, f)
    else:
        with open(os.path.join(output_dir, f"{filename}.pdf.pkl"), 'wb') as f:
            pickle.dump(grid, f)

Also, update the function call to match the new signature:

save_pkl_file(grid, args.output, f"page_{page}", args.model)

Steps to Reproduce

  1. Navigate to the VGT/object_detection/ directory
  2. Run the create_grid_input.py script
  3. Observe the TypeError

Expected Behavior

The script should run without errors and save the pickle file as intended.

Additional Context

This issue appears to be caused by a mismatch between the function definition and its usage. The proposed solution adjusts both to ensure they are consistent.

@CLAassistant
Copy link

CLAassistant commented Jul 15, 2024

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants