qurator-spk / eynollah

Document Layout Analysis
Apache License 2.0
332 stars 27 forks source link

drop_capitals.py: ValueError: attempt to get argmin of an empty sequence #47

Closed andbue closed 2 years ago

andbue commented 3 years ago

Hi, I think I found another one:

wget https://api.digitale-sammlungen.de/iiif/image/v2/bsb00052981_00339/full/full/0/default.png
eynollah -i default.png -o . -m eynollah/models_eynollah -fl -cl
13:16:03.204 INFO eynollah - resize and enhance image
13:16:03.204 INFO eynollah - Detected 230 DPI
13:16:19.326 INFO eynollah - Found 3 columns ([[1.6621375e-26 1.6978607e-38 1.0000000e+00 2.5424867e-32 9.4024474e-31
  0.0000000e+00]])
13:16:33.584 INFO eynollah - Image is enhanced
13:16:33.726 INFO eynollah - Enhancing took 30.522119998931885s
13:16:39.280 INFO eynollah - Image dimensions: 448x672
13:16:58.684 INFO eynollah - Image dimensions: 448x672
13:17:19.415 INFO eynollah - Image dimensions: 448x672
13:17:39.792 INFO eynollah - ratio_of_two_models: 99.93604678448163
13:17:40.588 INFO eynollah - Textregion detection took 66.86148571968079s
13:17:47.636 INFO eynollah - Graphics detection took 7.048167943954468s
13:17:47.636 INFO eynollah - cont_page [array([[  88,   87],
       [2933,   87],
       [2933, 4525],
       [  88, 4525]])]
13:17:52.956 INFO eynollah - Image dimensions: 448x672
13:18:04.696 INFO eynollah - textline detection took 17.060104370117188s
13:18:21.939 INFO eynollah - slope_deskew: -0.3636363636363633
13:18:21.939 INFO eynollah - deskewing took 17.242716073989868s
13:18:21.962 INFO eynollah - detection of marginals took 0.022979736328125s
13:18:27.893 INFO eynollah - Image dimensions: 896x896
13:18:33.513 INFO eynollah - Image dimensions: 896x896
13:18:53.899 INFO eynollah - areas_cnt_text [6.06679334e-05 3.96004787e-08 1.24939510e-03 1.53873996e-02
 3.28577052e-03 5.43809614e-03 5.36713208e-03 6.94196391e-05
 1.72341283e-04 1.30660354e-01 1.54637414e-01 7.77194243e-02
 3.97628407e-04 1.18769756e-03 4.26853560e-04]
Traceback (most recent call last):
  File "/.../bin/eynollah", line 33, in <module>
  File "/.../lib/python3.7/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/.../lib/python3.7/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/.../lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/.../lib/python3.7/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/.../lib/python3.7/site-packages/qurator/eynollah/cli.py", line 142, in main
    pcgts = eynollah.run()
  File "/.../lib/python3.7/site-packages/qurator/eynollah/eynollah.py", line 2024, in run
    all_found_texline_polygons = adhere_drop_capital_region_into_corresponding_textline(text_regions_p, polygons_of_drop_capitals, contours_only_text_parent, contours_only_text_parent_h, all_box_coord, all_box_coord_h, all_found_texline_polygons, all_found_texline_polygons_h, kernel=KERNEL, curved_line=self.curved_line)
  File "/.../lib/python3.7/site-packages/qurator/eynollah/utils/drop_capitals.py", line 157, in adhere_drop_capital_region_into_corresponding_textline
    arg_min = np.argmin(np.abs(y_lines - y_min_d[i_drop]))
  File "<__array_function__ internals>", line 6, in argmin
  File "/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1267, in argmin
    return _wrapfunc(a, 'argmin', axis=axis, out=out)
  File "/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
    return bound(*args, **kwds)
ValueError: attempt to get argmin of an empty sequence
vahidrezanezhad commented 3 years ago

Hi, I think I found another one:

wget https://api.digitale-sammlungen.de/iiif/image/v2/bsb00052981_00339/full/full/0/default.png
eynollah -i default.png -o . -m eynollah/models_eynollah -fl -cl
13:16:03.204 INFO eynollah - resize and enhance image
13:16:03.204 INFO eynollah - Detected 230 DPI
13:16:19.326 INFO eynollah - Found 3 columns ([[1.6621375e-26 1.6978607e-38 1.0000000e+00 2.5424867e-32 9.4024474e-31
  0.0000000e+00]])
13:16:33.584 INFO eynollah - Image is enhanced
13:16:33.726 INFO eynollah - Enhancing took 30.522119998931885s
13:16:39.280 INFO eynollah - Image dimensions: 448x672
13:16:58.684 INFO eynollah - Image dimensions: 448x672
13:17:19.415 INFO eynollah - Image dimensions: 448x672
13:17:39.792 INFO eynollah - ratio_of_two_models: 99.93604678448163
13:17:40.588 INFO eynollah - Textregion detection took 66.86148571968079s
13:17:47.636 INFO eynollah - Graphics detection took 7.048167943954468s
13:17:47.636 INFO eynollah - cont_page [array([[  88,   87],
       [2933,   87],
       [2933, 4525],
       [  88, 4525]])]
13:17:52.956 INFO eynollah - Image dimensions: 448x672
13:18:04.696 INFO eynollah - textline detection took 17.060104370117188s
13:18:21.939 INFO eynollah - slope_deskew: -0.3636363636363633
13:18:21.939 INFO eynollah - deskewing took 17.242716073989868s
13:18:21.962 INFO eynollah - detection of marginals took 0.022979736328125s
13:18:27.893 INFO eynollah - Image dimensions: 896x896
13:18:33.513 INFO eynollah - Image dimensions: 896x896
13:18:53.899 INFO eynollah - areas_cnt_text [6.06679334e-05 3.96004787e-08 1.24939510e-03 1.53873996e-02
 3.28577052e-03 5.43809614e-03 5.36713208e-03 6.94196391e-05
 1.72341283e-04 1.30660354e-01 1.54637414e-01 7.77194243e-02
 3.97628407e-04 1.18769756e-03 4.26853560e-04]
Traceback (most recent call last):
  File "/.../bin/eynollah", line 33, in <module>
  File "/.../lib/python3.7/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/.../lib/python3.7/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/.../lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/.../lib/python3.7/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/.../lib/python3.7/site-packages/qurator/eynollah/cli.py", line 142, in main
    pcgts = eynollah.run()
  File "/.../lib/python3.7/site-packages/qurator/eynollah/eynollah.py", line 2024, in run
    all_found_texline_polygons = adhere_drop_capital_region_into_corresponding_textline(text_regions_p, polygons_of_drop_capitals, contours_only_text_parent, contours_only_text_parent_h, all_box_coord, all_box_coord_h, all_found_texline_polygons, all_found_texline_polygons_h, kernel=KERNEL, curved_line=self.curved_line)
  File "/.../lib/python3.7/site-packages/qurator/eynollah/utils/drop_capitals.py", line 157, in adhere_drop_capital_region_into_corresponding_textline
    arg_min = np.argmin(np.abs(y_lines - y_min_d[i_drop]))
  File "<__array_function__ internals>", line 6, in argmin
  File "/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1267, in argmin
    return _wrapfunc(a, 'argmin', axis=axis, out=out)
  File "/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
    return bound(*args, **kwds)
ValueError: attempt to get argmin of an empty sequence

Can you please provide us the input image?

andbue commented 3 years ago

Hi, I think I found another one:

wget https://api.digitale-sammlungen.de/iiif/image/v2/bsb00052981_00339/full/full/0/default.png

... or right here as a link.

vahidrezanezhad commented 3 years ago

Sorry I didn't notice that the link is already there :) Thank you by the way

andbue commented 3 years ago

Thank you for the quick fix!

cneud commented 2 years ago

@andbue Can this be closed?

andbue commented 2 years ago

Yes, the commit has been merged by now.