mittagessen / kraken

OCR engine for all the languages
http://kraken.re
Apache License 2.0
751 stars 131 forks source link

Error on segmenting image (shapely-1.8.5) #575

Closed johnlockejrr closed 7 months ago

johnlockejrr commented 8 months ago

I try to segment an image under eScriptorium but I get this error and all is messed up

[2024-03-01 09:59:49,900: WARNING/ForkPoolWorker-9] Running binary model on non-binary input image (mode RGB). This will result in severely degraded performance
[2024-03-01 09:59:53,523: INFO/ForkPoolWorker-9] Vectorizing regions
[2024-03-01 09:59:54,022: INFO/ForkPoolWorker-9] Vectorizing baselines
[2024-03-01 09:59:58,512: ERROR/ForkPoolWorker-9] TopologyException: side location conflict at 239.08493353028064 1009.7939438700148. This can occur if the input geometry is invalid.
[2024-03-01 09:59:58,512: WARNING/ForkPoolWorker-9] Polygonizer failed on line 0: No Shapely geometry can be created from null value
[2024-03-01 10:00:07,562: INFO/ForkPoolWorker-9] Compute reading order on 33 lines in rl direction
[2024-03-01 10:00:07,574: INFO/ForkPoolWorker-9] Perform topological sort on partially ordered lines
[2024-03-01 10:00:07,575: INFO/ForkPoolWorker-9] Compute reading order on 1 lines in rl direction
[2024-03-01 10:00:07,575: INFO/ForkPoolWorker-9] Perform topological sort on partially ordered lines
[2024-03-01 10:00:07,575: INFO/ForkPoolWorker-9] Compute reading order on 34 lines in rl direction
[2024-03-01 10:00:07,589: INFO/ForkPoolWorker-9] Perform topological sort on partially ordered lines
[2024-03-01 10:00:09,781: INFO/ForkPoolWorker-9] Task core.tasks.segment[5e91049a-9e08-44f2-beb3-3275b21a58d5] succeeded in 20.952682676026598s: None

So I tried under latest kraken 4.3.10

(env) incognito@Nobody-Lap:~/kraken/train_sam$ kraken -d cuda:0 -i /home/incognito/escriptorium/app/media/documents/30/137.jpg -a segment -bl -i /home/incognito/escriptorium/app/media/models/c8b95dd3/sam_multi_seg-v1_best.mlmodel
scikit-learn version 1.2.2 is not supported. Minimum required version: 0.17. Maximum required version: 1.1.2. Disabling scikit-learn conversion API.
Loading ANN /home/incognito/escriptorium/app/media/models/c8b95dd3/sam_multi_seg-v1_best.mlmodel        ✓
Segmenting      [03/01/24 11:16:02] WARNING  Running binary model on non-binary input image (mode RGB). This will result in severely degraded performance
      blla.py:80
TopologyException: side location conflict at 239.08493353028064 1009.7939438700148. This can occur if the input geometry is invalid.
[03/01/24 11:16:11] WARNING  Polygonizer failed on line 0: No Shapely geometry can be created from null value                                                                                 segmentation.py:735
✓

Found on an old issue that shapely-1.7.1 would work so I downgraded and tried with success but it seems is not compatible with latest kraken

(env) incognito@Nobody-Lap:~/kraken/train_sam$ pip install --upgrade "shapely==1.7.1"
Collecting shapely==1.7.1
  Downloading Shapely-1.7.1-cp38-cp38-manylinux1_x86_64.whl (1.0 MB)
     |████████████████████████████████| 1.0 MB 10.2 MB/s
ERROR: kraken 4.3.10 has requirement shapely==1.8.5, but you'll have shapely 1.7.1 which is incompatible.
Installing collected packages: shapely
  Attempting uninstall: shapely
    Found existing installation: Shapely 1.8.5
    Uninstalling Shapely-1.8.5:
      Successfully uninstalled Shapely-1.8.5
Successfully installed shapely-1.7.1
(env) incognito@Nobody-Lap:~/kraken/train_sam$ kraken -d cuda:0 -i /home/incognito/escriptorium/app/media/documents/30/137.jpg -a segment -bl -i /home/incognito/escriptorium/app/media/models/c8b95dd3/sam_multi_seg-v1_best.mlmodel
scikit-learn version 1.2.2 is not supported. Minimum required version: 0.17. Maximum required version: 1.1.2. Disabling scikit-learn conversion API.
Loading ANN /home/incognito/escriptorium/app/media/models/c8b95dd3/sam_multi_seg-v1_best.mlmodel        ✓
Segmenting      [03/01/24 11:19:06] WARNING  Running binary model on non-binary input image (mode RGB). This will result in severely degraded performance
      blla.py:80
✓

What to do next?

mittagessen commented 8 months ago

Shapely 1.8.5 is the only version that works with kraken. That's why is it pinned.

Lines that fail the polygonizer are usually erroneous detections from the segmentation net. Ignoring the warning should be safe.

johnlockejrr commented 8 months ago

By the way, is there a kraken discussion platform somewhere? Gitlab or anyhing? Thanks!

On Fri, 1 Mar 2024 at 12:27, mittagessen @.***> wrote:

Shapely 1.8.5 is the only version that works with kraken. That's why is it pinned.

Lines that fail the polygonizer are usually erroneous detections from the segmentation net. Ignoring the warning should be safe.

— Reply to this email directly, view it on GitHub https://github.com/mittagessen/kraken/issues/575#issuecomment-1973017344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD44GHW2Q7NE6FKIEAOV4XTYWBQZZAVCNFSM6AAAAABEBQPOJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZTGAYTOMZUGQ . You are receiving this because you authored the thread.Message ID: @.***>

dstoekl commented 8 months ago

closest is probably the eScr gitter.


De : johnlockejrr @.> Envoyé : mardi 5 mars 2024 00:40 À : mittagessen/kraken @.> Cc : Subscribed @.***> Objet : Re: [mittagessen/kraken] Error on segmenting image (shapely-1.8.5) (Issue #575)

By the way, is there a kraken discussion platform somewhere? Gitlab or anyhing? Thanks!

On Fri, 1 Mar 2024 at 12:27, mittagessen @.***> wrote:

Shapely 1.8.5 is the only version that works with kraken. That's why is it pinned.

Lines that fail the polygonizer are usually erroneous detections from the segmentation net. Ignoring the warning should be safe.

— Reply to this email directly, view it on GitHub https://github.com/mittagessen/kraken/issues/575#issuecomment-1973017344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD44GHW2Q7NE6FKIEAOV4XTYWBQZZAVCNFSM6AAAAABEBQPOJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZTGAYTOMZUGQ . You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/mittagessen/kraken/issues/575#issuecomment-1977659251, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJNUE3Z6X3QY24GYNM5GSB3YWUA7ZAVCNFSM6AAAAABEBQPOJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZXGY2TSMRVGE. You are receiving this because you are subscribed to this thread.

johnlockejrr commented 8 months ago

Sorry, not related, is there a kraken 4.3.13 version? I saw that in eScriptorium requirements.txt dev on github "kraken~=4.3.13"? Thanks!

mittagessen commented 8 months ago

On 24/03/08 01:34PM, johnlockejrr wrote:

Sorry, not related, is there a kraken 4.3.13 version? I saw that in eScriptorium requirements.txt dev on github "kraken~=4.3.13"?

Yes, there's a 4.3.13 that should be both on conda and pypi.

johnlockejrr commented 8 months ago

Thanks, I didn't see it in /releases so I thought is a typo on their side