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

Error: zero-size array to reduction #126

Open
jbarth-ubhd opened this issue May 2, 2024 · 6 comments
Open

Error: zero-size array to reduction #126

jbarth-ubhd opened this issue May 2, 2024 · 6 comments

Comments

@jbarth-ubhd
Copy link

ERROR eynollah - zero-size array to reduction operation minimum which has no identity

presumably eynollah returned exit-status > 0.

Workflow see run.sh in https://digi.ub.uni-heidelberg.de/diglitData/v/duerer1527_-_0_i.tgz

@jbarth-ubhd
Copy link
Author

Ok scan does not contain text: https://digi.ub.uni-heidelberg.de/diglit/duerer1527/0009/image,info

@jbarth-ubhd
Copy link
Author

jbarth-ubhd commented May 2, 2024

there are more errors on this book

jb@pers109:/.../duerer1527/run4> egrep -ih 'fail|not supp|error|fatal' */ocrd.log|sed 's/..:..:...... //g'|sort|uniq -c|sort -n
      3 ERROR eynollah - zero-size array to reduction operation minimum which has no identity
     18 ERROR ocrd.processor.helpers.run_processor - Failure in processor 'ocrd-eynollah-segment'
     36 >  - contour data type = object is not supported
     36 cv2.error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'contourArea'
     36 > Overload resolution failed:

@jbarth-ubhd
Copy link
Author

Did docker pull ocrd/all:maximum 2024-09-25 and tried it again. Does still not work:

+ docker run --rm -u 0 -v /home/jb/duerer1527/run4/0_i:/data -v /home/jb/ocrd-models:/models -- ocrd/all:maximum ocrd-eynollah-segment -P models default -I OCR-D-004 -O OCR-D-005
16:25:18.982 INFO eynollah - INPUT FILE P_00001 (1/1) 
16:25:20.648 INFO eynollah - Resizing and enhancing image...
16:25:20.649 INFO eynollah - Detected 600 DPI
16:25:41.426 INFO eynollah - Found 1 columns ([[9.9996e-01 4.0000e-05 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00]])
16:25:41.446 INFO eynollah - detecting columns took 20.7s
16:25:41.480 INFO eynollah - Image was not enhanced.
16:25:41.641 INFO eynollah - Enhancing took 21.0s 
16:34:35.386 INFO eynollah - Textregion detection took 533.7s 
16:34:37.622 INFO eynollah - Graphics detection took 2.2s 
16:36:55.832 INFO eynollah - textline detection took 138.2s
16:37:58.427 INFO eynollah - slope_deskew: -90.00°
16:37:58.427 INFO eynollah - deskewing took 62.6s
16:37:58.931 INFO eynollah - detection of marginals took 0.5s
16:40:08.448 ERROR ocrd.processor.helpers.run_processor - Failure in processor 'ocrd-eynollah-segment'
Traceback (most recent call last):
  File "/build/core/src/ocrd/processor/helpers.py", line 130, in run_processor
    processor.process()
  File "/build/eynollah/qurator/eynollah/processor.py", line 63, in process
    Eynollah(**eynollah_kwargs).run()
  File "/build/eynollah/qurator/eynollah/eynollah.py", line 2277, in run
    cx_bigest, cy_biggest, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent)
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in find_new_features_of_contours
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in <listcomp>
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'contourArea'
> Overload resolution failed:
>  - contour data type = object is not supported
>  - Expected Ptr<cv::UMat> for argument 'contour'

Traceback (most recent call last):
  File "/usr/local/bin/ocrd-eynollah-segment", line 33, in <module>
    sys.exit(load_entry_point('eynollah', 'console_scripts', 'ocrd-eynollah-segment')())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/build/eynollah/qurator/eynollah/ocrd_cli.py", line 8, in main
    return ocrd_cli_wrap_processor(EynollahProcessor, *args, **kwargs)
  File "/build/core/src/ocrd/decorators/__init__.py", line 152, in ocrd_cli_wrap_processor
    run_processor(processorClass, mets_url=mets, workspace=workspace, **kwargs)
  File "/build/core/src/ocrd/processor/helpers.py", line 133, in run_processor
    raise err
  File "/build/core/src/ocrd/processor/helpers.py", line 130, in run_processor
    processor.process()
  File "/build/eynollah/qurator/eynollah/processor.py", line 63, in process
    Eynollah(**eynollah_kwargs).run()
  File "/build/eynollah/qurator/eynollah/eynollah.py", line 2277, in run
    cx_bigest, cy_biggest, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent)
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in find_new_features_of_contours
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in <listcomp>
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'contourArea'
> Overload resolution failed:
>  - contour data type = object is not supported
>  - Expected Ptr<cv::UMat> for argument 'contour'

@jbarth-ubhd
Copy link
Author

Workflow:

#!/bin/sh
set -e
set -x

singocrd () {
		docker run --rm -u $(id -u) -v $PWD:/data -v /home/jb/ocrd-models:/models -- ocrd/all:maximum "$@"
}

singocrd ocrd workspace init
singocrd ocrd workspace add -g P_00001 -G OCR-D-IMG -i OCR-D-IMG_00001 -m image/tiff OCR-D-IMG/00001.tif

singocrd ocrd-olena-binarize -P impl wolf -P k 0.10 -I OCR-D-IMG -O OCR-D-001
singocrd ocrd-tesserocr-crop -I OCR-D-001 -O OCR-D-002
singocrd ocrd-olena-binarize -P impl wolf -P k 0.10 -I OCR-D-002 -O OCR-D-003
singocrd ocrd-cis-ocropy-deskew -P level-of-operation page -I OCR-D-003 -O OCR-D-004
singocrd ocrd-eynollah-segment -P models default -I OCR-D-004 -O OCR-D-005
singocrd ocrd-tesserocr-recognize -P textequiv_level word -P model deu -I OCR-D-005 -O OCR-D-OCR

@vahidrezanezhad
Copy link
Member

Did docker pull ocrd/all:maximum 2024-09-25 and tried it again. Does still not work:

+ docker run --rm -u 0 -v /home/jb/duerer1527/run4/0_i:/data -v /home/jb/ocrd-models:/models -- ocrd/all:maximum ocrd-eynollah-segment -P models default -I OCR-D-004 -O OCR-D-005
16:25:18.982 INFO eynollah - INPUT FILE P_00001 (1/1) 
16:25:20.648 INFO eynollah - Resizing and enhancing image...
16:25:20.649 INFO eynollah - Detected 600 DPI
16:25:41.426 INFO eynollah - Found 1 columns ([[9.9996e-01 4.0000e-05 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00]])
16:25:41.446 INFO eynollah - detecting columns took 20.7s
16:25:41.480 INFO eynollah - Image was not enhanced.
16:25:41.641 INFO eynollah - Enhancing took 21.0s 
16:34:35.386 INFO eynollah - Textregion detection took 533.7s 
16:34:37.622 INFO eynollah - Graphics detection took 2.2s 
16:36:55.832 INFO eynollah - textline detection took 138.2s
16:37:58.427 INFO eynollah - slope_deskew: -90.00°
16:37:58.427 INFO eynollah - deskewing took 62.6s
16:37:58.931 INFO eynollah - detection of marginals took 0.5s
16:40:08.448 ERROR ocrd.processor.helpers.run_processor - Failure in processor 'ocrd-eynollah-segment'
Traceback (most recent call last):
  File "/build/core/src/ocrd/processor/helpers.py", line 130, in run_processor
    processor.process()
  File "/build/eynollah/qurator/eynollah/processor.py", line 63, in process
    Eynollah(**eynollah_kwargs).run()
  File "/build/eynollah/qurator/eynollah/eynollah.py", line 2277, in run
    cx_bigest, cy_biggest, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent)
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in find_new_features_of_contours
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in <listcomp>
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'contourArea'
> Overload resolution failed:
>  - contour data type = object is not supported
>  - Expected Ptr<cv::UMat> for argument 'contour'

Traceback (most recent call last):
  File "/usr/local/bin/ocrd-eynollah-segment", line 33, in <module>
    sys.exit(load_entry_point('eynollah', 'console_scripts', 'ocrd-eynollah-segment')())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/build/eynollah/qurator/eynollah/ocrd_cli.py", line 8, in main
    return ocrd_cli_wrap_processor(EynollahProcessor, *args, **kwargs)
  File "/build/core/src/ocrd/decorators/__init__.py", line 152, in ocrd_cli_wrap_processor
    run_processor(processorClass, mets_url=mets, workspace=workspace, **kwargs)
  File "/build/core/src/ocrd/processor/helpers.py", line 133, in run_processor
    raise err
  File "/build/core/src/ocrd/processor/helpers.py", line 130, in run_processor
    processor.process()
  File "/build/eynollah/qurator/eynollah/processor.py", line 63, in process
    Eynollah(**eynollah_kwargs).run()
  File "/build/eynollah/qurator/eynollah/eynollah.py", line 2277, in run
    cx_bigest, cy_biggest, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent)
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in find_new_features_of_contours
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
  File "/build/eynollah/qurator/eynollah/utils/contour.py", line 80, in <listcomp>
    areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))])
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'contourArea'
> Overload resolution failed:
>  - contour data type = object is not supported
>  - Expected Ptr<cv::UMat> for argument 'contour'

@jbarth-ubhd Could you please provide the image? I need to reproduce the error first.

@jbarth-ubhd
Copy link
Author

Is in https://digi.ub.uni-heidelberg.de/diglitData/v/duerer1527_-_0_i.tgz , see first post. Named duerer1527/run4/0_i/0_i.tif in .tgz. Need top copy to OCR-D-IMG/00001.tif

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