Udayraj123 / OMRChecker

Evaluate OMR sheets fast and accurately using a scanner 🖨 or your phone 🤳.
MIT License
735 stars 304 forks source link

[Feature] Support CLI arguments for passing the configuration files #201

Open Udayraj123 opened 1 month ago

Udayraj123 commented 1 month ago

Is your feature request related to a problem? Please describe. We should support CLI arguments for passing the configuration files such as template.json, config.json and evaluation.json

Describe the solution you'd like We can use these names for the args

python3 main.py [<existing args>] [--templateFile <path>] [--evaluationFile <path>] [--configFile <path>]

Describe alternatives you've considered As of now we need to make sure the file exists in the --inputDir folder.

Additional context This would be a small change for beginners to understand how directory parsing works in OMRChecker currently.

VidhuSarwal commented 1 month ago

Hi, I am interested in doing this, Rather I have started work on it, Since this my first time doing something like this, will take some time, but so far have figured out basic plan.

1) Add three new arguments, --templateFile, --evaluationFile, --configFile in parse_args of main.py 2) Modify the process_dir function in entry.py so that it takes the new attributes passed by entry_point_for_args to entry_point in entry.py. Will modify it such that for Eg. If a template_file argument is provided, use it instead of looking for the file. Else, Raise an exception.

VidhuSarwal commented 1 month ago

Ok, So I am able to pass config.json and template.json file via CLI, but the evaluationFile for example, sheet1.jpg, on passing it throws the error UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 176: character maps to <undefined>

The traceback for it is below. File "C:\Users\Users\Documents\OMR\OMRChecker\main.py", line 120, in <module> entry_point_for_args(args) File "C:\Users\Users\Documents\OMR\OMRChecker\main.py", line 112, in entry_point_for_args entry_point( File "C:\Users\Users\Documents\OMR\OMRChecker\src\entry.py", line 36, in entry_point return process_dir(input_dir, curr_dir, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Users\Documents\OMR\OMRChecker\src\entry.py", line 113, in process_dir evaluation_config = EvaluationConfig(curr_dir, evaluation_path, template, tuning_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Users\Documents\OMR\OMRChecker\src\evaluation.py", line 193, in __init__ evaluation_json = open_evaluation_with_validation(evaluation_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Users\Documents\OMR\OMRChecker\src\utils\parsing.py", line 66, in open_evaluation_with_validation user_evaluation_config = load_json(evaluation_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Users\Documents\OMR\OMRChecker\src\utils\file.py", line 15, in load_json loaded = json.load(f, **rest) ^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation\Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\json\__init__.py", line 293, in load return loads(fp.read(), ^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation\Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input, self.errors, decoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 176: character maps to <undefined>

However, The code works perfectly if I place the jpg file in inputs folder and config and template are passed through CLI.

palash018 commented 1 month ago

@VidhuSarwal, could you try it with other samples as well and check if they produce the same error? . Please join Discord for further discussion.

Udayraj123 commented 1 month ago

@VidhuSarwal possible to discuss over discord? I've created a thread here

https://discord.com/channels/590134763784896514/1269271619398930455/1269271648318652466

Also would like to get your introduction over there :)

VidhuSarwal commented 1 month ago

Yeah sure! I will join the discord server.

Edit : The link is not working, I am getting the below error.

image

Udayraj123 commented 1 month ago

@VidhuSarwal please the check the link from Readme.

Usool-Data-Science commented 1 day ago

@Udayraj123 It seems this issue is still open, please assign it to me so I can implement the required feature.

Udayraj123 commented 20 hours ago

No problem, @Usool-Data-Science, please share an approach you'd like to try here. I'll assign you the issue