OCR-D / ocrd_tesserocr

Run tesseract with the tesserocr bindings with @OCR-D's interfaces
MIT License
38 stars 11 forks source link

Invalid parameter - not of type boolean #194

Closed MehmedGIT closed 1 year ago

MehmedGIT commented 1 year ago

Although I see the reason behind this error, I wonder if it is just not better to try parsing string parameters to a boolean where a boolean is expected.

Caused by:
  Process `ocrd_tesserocr_segment` terminated with an error exit status (1)

Command executed:

  singularity exec --bind /scratch1/users/mmustaf/operandi/slurm_workspaces/94200a5d-f332-4391-8699-92fbf81b4e7e --bind /scratch1/users/mmustaf/ocrd_models:/usr/local/share --env OCRD_METS_CACHING=true /scratch1/users/mmustaf/ocrd_all_maximum_image.sif ocrd-tesserocr-segment -m mets.xml -I OCR-D-BIN-DENOISE-DESKEW -O OCR-D-SEG -p '{"shrink_polygons": "true"}'

Command exit status:
  1

Command output:
  (empty)

Command error:
  Traceback (most recent call last):
    File "/usr/local/bin/ocrd-tesserocr-segment", line 33, in <module>
      sys.exit(load_entry_point('ocrd-tesserocr', 'console_scripts', 'ocrd-tesserocr-segment')())
    File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
      return self.main(*args, **kwargs)
    File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1055, in main
      rv = self.invoke(ctx)
    File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
      return ctx.invoke(self.callback, **ctx.params)
    File "/usr/local/lib/python3.8/site-packages/click/core.py", line 760, in invoke
      return __callback(*args, **kwargs)
    File "/build/ocrd_tesserocr/ocrd_tesserocr/cli.py", line 18, in ocrd_tesserocr_segment
      return ocrd_cli_wrap_processor(TesserocrSegment, *args, **kwargs)
    File "/build/core/ocrd/ocrd/decorators/__init__.py", line 151, in ocrd_cli_wrap_processor
      run_processor(processorClass, mets_url=mets, workspace=workspace, **kwargs)
    File "/build/core/ocrd/ocrd/processor/helpers.py", line 86, in run_processor
      processor = get_processor(
    File "/build/core/ocrd/ocrd/processor/helpers.py", line 342, in get_processor
      return processor_class(
    File "/build/ocrd_tesserocr/ocrd_tesserocr/segment.py", line 15, in __init__
      super().__init__(*args, **kwargs)
    File "/build/ocrd_tesserocr/ocrd_tesserocr/recognize.py", line 130, in __init__
      super().__init__(*args, **kwargs)
    File "/build/core/ocrd/ocrd/processor/base.py", line 149, in __init__
      raise Exception("Invalid parameters %s" % report.errors)
  Exception: Invalid parameters ["[shrink_polygons] 'true' is not of type 'boolean'"]
bertsky commented 1 year ago

-p '{"shrink_polygons": "true"}' should be -p '{"shrink_polygons": true}' or simply -P shrink_polygons true. The latter will already try to do type casting (although in a limited fashion).

Anyway, this is not a ocrd_tesserocr issue, it belongs to core. But see https://github.com/OCR-D/core/issues/950 for the problems that casting can cause.

MehmedGIT commented 1 year ago

Thanks for referencing 950. That helps to understand why a certain decision was made regarding parameters.