mittagessen / kraken

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

Problem with assigning a line to a region if it's too close to the region border #650

Open fattynoparents opened 1 week ago

fattynoparents commented 1 week ago

I'm running kraken segmentation inference with the following command, including two different models for baselines- and regions- recognition:

kraken -r -d cuda:0 -x -I "$KRAKEN_IN" -o "$KRAKEN_OUT" segment -bl --model $KRAKENBASELINEMODEL --model $KRAKENREGIONMODEL

There arise some cases when a baseline goes too close the border to a region and then the kraken engine fails to assign it to this region. In eScriptorium it looks like the baseline is assigned to the rose region: 1 However if I look closer, the baseline is not assigned and cannot be assigned even manually: 2

Here are also the corresponding parts from XML files that I get from kraken. The dummy region to which the above mentioned baseline is assigned:

<TextRegion id="textblock_2">
            <Coords points="0,0 0,3057 2443,3057 2443,0"/>

            <TextLine id="6a3e0481-9a54-44d8-b811-2ee129557a4a" custom="structure {type:default;}">
                <Coords points="1634,455 1595,439 1593,439 1591,439 1590,439 1564,451 1522,407 1522,405 1520,405 1518,405 1435,405 1433,405 1432,405 1430,405 1369,451 1331,451 1284,404 1284,402 1282,402 1280,402 1238,402 1236,402 1235,402 1233,402 1233,404 1202,434 1185,426 1184,426 1043,424 1041,424 1039,424 1019,436 987,414 985,414 983,414 981,414 980,414 978,414 929,444 895,444 878,478 878,494 898,485 1005,495 1007,495 1051,485 1065,495 1065,497 1066,497 1068,497 1070,497 1071,497 1097,485 1124,497 1126,497 1128,497 1129,497 1156,490 1253,499 1255,499 1257,499 1258,499 1258,497 1265,492 1275,501 1277,501 1279,501 1280,501 1343,489 1445,499 1447,499 1586,494 1600,502 1602,502 1603,502 1605,502 1649,492 1651,490 1634,455"/>
                <Baseline points="878,478 1100,480 1194,489 1374,482 1651,490"/>

            </TextLine>

        </TextRegion>

and the empty Författare region to which the baseline should ACTUALLY be assigned:

<TextRegion id="bf083ecd-784c-497c-96e1-1d1099cd3631" custom="structure {type:Författare;}">
         <Coords points="869,346 1607,353 1647,366 1634,467 1654,487 829,473 795,434 822,360 869,346"/>        
</TextRegion>

Is it something that can be fixed somehow? Thanks in advance.

jesusbft commented 1 week ago

Did you try training a baseline labeling model? Maybe you solve this issue with your own model.

If not, is the command ketos segtrain

fattynoparents commented 1 week ago

Did you try training a baseline labeling model? Maybe you solve this issue with your own model.

Yes this is my trained models, both baseline- and regionmodel. I finetuned them separately with --suppress-regions and --suppress-baselines parameters.