AdvancedLiterateMachinery
AdvancedLiterateMachinery copied to clipboard
Update create_grid_input.py
trafficstars
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
- Navigate to the
VGT/object_detection/directory - Run the
create_grid_input.pyscript - 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.