bertsky/ocrd_detectron2

Exception using -P debug_img instance_colors

Closed this issue ยท 7 comments

I have got an exception using Parameter -P debug_img instance_colors
I have called:

 ocrd-detectron2-segment -I OCR-D-BIN -O OCR-D-DETECTRON2-DocBank_X101-debug -p /home/ocrdadmin/ocrd-3.7/sub-venv/headless-tf1/lib/python3.7/site-packages/ocrd_detectron2/presets_DocBank_X101.json -P debug_img instance_colors -l TRACE

See logfile here:
debug.log
Just guessing: Maybe problems with processing more than one image and/or more than one region ?

kba commented

Please try #19, it's another single-line change that lets me process successfully with your call.

Tried out #19 - works better but still has an issue:

  • Good: I do not get an exception anymore.
  • But, too many images are created (for each paragraph on a page the same image) -> expectation would be just one image per page
    --> see this PAGE extract:
   <pc:Page imageFilename="OCR-D-IMG/00001.tif" imageWidth="3907" imageHeight="5820" custom="coords=[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]" orientation="0.">
        <pc:AlternativeImage filename="OCR-D-BIN/OCR-D-BIN_00001.IMG-BIN.png" comments=",binarized"/>
        <pc:AlternativeImage filename="OCR-D-DETECTRON2-DocBank_X101-debug/OCR-D-DETECTRON2-DocBank_X101-debug_00001_region0001_TextRegion_paragraph.IMG-DEBUG.png" comments="debug"/>
        <pc:AlternativeImage filename="OCR-D-DETECTRON2-DocBank_X101-debug/OCR-D-DETECTRON2-DocBank_X101-debug_00001_region0002_TextRegion_paragraph.IMG-DEBUG.png" comments="debug"/>
        <pc:AlternativeImage filename="OCR-D-DETECTRON2-DocBank_X101-debug/OCR-D-DETECTRON2-DocBank_X101-debug_00001_region0003_TextRegion_paragraph.IMG-DEBUG.png" comments="debug"/>
        <pc:AlternativeImage filename="OCR-D-DETECTRON2-DocBank_X101-debug/OCR-D-DETECTRON2-DocBank_X101-debug_00001_region0004_TextRegion_paragraph.IMG-DEBUG.png" comments="debug"/>
        <pc:TextRegion id="region0001_TextRegion_paragraph" type="paragraph">
            <pc:Coords points="1632,868 1632,920 
... 
    1836,870 1834,872 1672,872 1670,870 1670,868" conf="0.783987998962402"/>
        </pc:TextRegion>
        <pc:TextRegion id="region0002_TextRegion_paragraph" type="paragraph">
            <pc:Coords points="498,5646 498,5650 496,5652
... 
    634,5646 604,5646 604,5650 602,5652 538,5652 536,5650 536,5646" conf="0.690042674541473"/>
        </pc:TextRegion>
        <pc:TextRegion id="region0003_TextRegion_paragraph" type="paragraph">
            <pc:Coords points="3616,864 3616,918 3824,918 3826,916 3834,916 3834,866 3826,866 3824,864" conf="0.669966101646423"/>
        </pc:TextRegion>
        <pc:TextRegion id="region0004_TextRegion_paragraph" type="paragraph">
            <pc:Coords points="14,0 14,812 12,814 12,844 14,846 14,940
...
 3836,844 3836,814 3832,814 3830,812 3830,0" conf="0.639784932136536"/>
        </pc:TextRegion>
    </pc:Page>

kba commented

But, too many images are created (for each paragraph on a page the same image) -> expectation would be just one image per page

With img_debug, it is to be expected that these debug images are created per-region. But I am at my limit in understanding the code unfortunately, these should be region-specific IIUC but indeed are not, it's the page image rather. Me removing the distinction between page-level and region-level segments in #19 likely did not help.

So I'm afraid @bertsky has to weigh in once he's back.

@stefanCCS thanks for reporting! I made a mistake with the scope (indentation) of the debug_img writer. Sorry for being careless. Fixed on master, please retry.

@kba answering in your PR.

@stefanCCS can we close this?

Sorry, have not tested it yet.
I hope I can do this within the next two weeks.
Of course, you may remind me from time-to-time ;-)

Works fine
Tested with https://github.com/OCR-D/ocrd_all/releases/tag/v2023-06-14 (non GPU machine)
Will close this issue now.