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

Issue with de-warp - strange result #42

Open
stefanCCS opened this issue Feb 14, 2020 · 22 comments
Open

Issue with de-warp - strange result #42

stefanCCS opened this issue Feb 14, 2020 · 22 comments

Comments

@stefanCCS
Copy link

Hi Martin,
we met shortly in Bonn.
You have explained the de-warping which was very interesting for me.
I have tried out a bit - and after some environment issues, I could run it.
Unfortunately, the results (visible as image in OCR-D-IMG-DEWARP) looks very strange.
Maybe I have used wrong parameters.
I have used the model which is decribed in anybaseocr/models/readme.md:
https://cloud.dfki.de/owncloud/index.php/s/3zKza5sRfQB3ygy
I have used the following parameter sets:
{
"gpu_id":0,
"pix2pixHD":"/home/stefan/ocrd_all/pix2pixHD",
"model_name":"/home/stefan/ocrd_all/pix2pixHD/models/"
}
You can download the image examples here:
ftp://ftp.ccs-gmbh.net (directory example1)
User: OCRDExamples
Password: OcRd%123!

@bertsky
Copy link
Contributor

bertsky commented Feb 17, 2020

@stefanCCS that ftp server seems to be down. And it would be way easier if you just pasted the images here. Github then takes care of hosting them and you can immediately see them when browsing the issue.

@stefanCCS
Copy link
Author

@stefanCCS that ftp server seems to be down. And it would be way easier if you just pasted the images here. Github then takes care of hosting them and you can immediately see them when browsing the issue.

I just have tried the FTP-access - and it has worked fine:
wget --user=OCRDExamples --password='OcRd%123!' ftp://ftp.ccs-gmbh.net/example1/*
--> Please try once more.

@kba
Copy link
Member

kba commented Feb 17, 2020

--> Please try once more.

Working now, though only via wget, not FileZilla for some reason. Unless there is a privacy problem (looks like dutch newspaper?), I'd also appreciate uploads to GitHub.

@stefanCCS
Copy link
Author

Ok, understood ;-)
Here you can find attached the cropped image, which was taken as input to the dewarp.
(I could not load the source image here, as it is too big).
OCR-D-IMG-CROP-1

@stefanCCS
Copy link
Author

Any update from somebody possible?

@kba
Copy link
Member

kba commented Mar 20, 2022

Hard to say but I think #89 should fix or at least improve the issue. @stefanCCS feel free to reopen if you still encounter strange results with the newest release.

@kba kba closed this as completed Mar 20, 2022
@stefanCCS
Copy link
Author

Hi @kba ,
just have tried out (with update done via ocrd_all at 22.03.2022.
I still get strange results (Image are very "blurry").
See e.g. this excerpt:
image

I cannot re-open this issue: Will you do it? Should I create a new one?

@kba kba reopened this Mar 24, 2022
@bertsky
Copy link
Contributor

bertsky commented Mar 24, 2022

@stefanCCS as I explained here, you have to set a different resize_mode and resize_width for better quality (resolution), esp. with such large images. Also see improved help text.

@stefanCCS
Copy link
Author

btw: I get this warning here - relevant ?

/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/torchvision/transforms/transforms.py:288: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
  "Argument interpolation should be of type InterpolationMode instead of int. "

@stefanCCS
Copy link
Author

Tried out with

  • resize_mode none
    ==> Result: One example works better, the other one gets "out-of-memory" with more than 8GB RAM to try to allocate

  • resize_mode resize_and_crop (default) and resize_width 2048 (instead of default 1024)

  • ==> Result: Both examples are still very blurred

  • resize_mode resize_and_crop (default) and resize_width 4096 (instead of default 1024)
    ==> Result: One example works better, the other one gets "out-of-memory" with more than 8GB RAM to try to allocate

All done on full page level.
Next try will be on region level ...

@stefanCCS
Copy link
Author

I have tried out on region level (-P operation_level region)
Then, I got the following exception
(looking in the output folder, the just 1 region-dewarped-image was created, and this filename does not have any substructure - expected would be something linke *_TR-1, which I get e.g. when using ocrd-cis-ocropy-binarize.)

  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/bin/ocrd-anybaseocr-dewarp", line 8, in <module>
    sys.exit(cli())
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py", line 210, in cli
    return ocrd_cli_wrap_processor(OcrdAnybaseocrDewarper, *args, **kwargs)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd/decorators/__init__.py", line 88, in ocrd_cli_wrap_processor
    run_processor(processorClass, ocrd_tool, mets, workspace=workspace, **kwargs)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd/processor/helpers.py", line 88, in run_processor
    processor.process()
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py", line 169, in process
    prepare_data(self.opt, region_image), region, region_xywh, region_image.size, input_file)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py", line 202, in _process_segment
    file_grp=self.output_file_grp,
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd/workspace.py", line 983, in save_image_file
    force=force)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd/workspace.py", line 365, in add_file
    ret = self.mets.add_file(file_grp, **kwargs)
  File "/home/ocrdadmin/ocrd_all/venv/sub-venv/headless-tf2/lib/python3.6/site-packages/ocrd_models/ocrd_mets.py", line 307, in add_file
    raise Exception("File with ID='%s' already exists" % ID)

@bertsky
Copy link
Contributor

bertsky commented Mar 24, 2022

btw: I get this warning here - relevant ?

no, not relevant. (string vs int mapping of interpolation types does work.)

@bertsky
Copy link
Contributor

bertsky commented Mar 24, 2022

  • Result: One example works better, the other one gets "out-of-memory" with more than 8GB RAM to try to allocate

Yes, it's memory-intensive for sure. That's by design, unfortunately. And it is a huge page.

Out of curiosity: have you tried on GPU as well?

@bertsky
Copy link
Contributor

bertsky commented Mar 24, 2022

raise Exception("File with ID='%s' already exists" % ID)

thanks for the report – can you please try again with newest #91?

@stefanCCS
Copy link
Author

  • Result: One example works better, the other one gets "out-of-memory" with more than 8GB RAM to try to allocate

Yes, it's memory-intensive for sure. That's by design, unfortunately. And it is a huge page.

Out of curiosity: have you tried on GPU as well?

No GPU available - work on getting one ...

For us this is not a huge page, it is a normal one - we sometimes get A1 newspapers with 600dpi - this is huge ;-)

@bertsky
Copy link
Contributor

bertsky commented Mar 25, 2022

For us this is not a huge page, it is a normal one - we sometimes get A1 newspapers with 600dpi - this is huge ;-)

I see. I would say this simply is not possible at the moment with our architecture – unless you invest insane amounts of RAM.

@stefanCCS
Copy link
Author

Maybe it works ok (in the meaning of RAM) on region level - I will try out ...

@stefanCCS
Copy link
Author

Have tried out on Region-Level.
Works ok with newest version 1.8.
"ok" means

  • no issue with amount of RAM
  • no issue with blurred results
  • and some dewarping done
    ==> in general ok (but very slow on CPU).

It is ok for me to close this issue now (shall I do this?)

@stefanCCS
Copy link
Author

Hi again,
last (for now) comment from my side.
I have tried out dewarping of a pretty strong warped region like this example here:
image

Unfortunately, the result is not better (somehow worse) - see here:
image

I would guess that the training has not seen this kind of strong warped examples.
Maybe something to be improved?

Anyway, issue can be closed as no software bug is open.

@bertsky
Copy link
Contributor

bertsky commented Mar 28, 2022

I would guess that the training has not seen this kind of strong warped examples.
Maybe something to be improved?

Yes, that's exactly what I would assume. Unfortunately, the developers never documented what they used for training.

I guess we'll just have to write/wrap parameteric dewarpers...

@stefanCCS
Copy link
Author

This brings me back to the idea, that ocrd-kraken-segment should learn "Regions-level". And with this lines, the dewarping should work ok.
What do you think?

@bertsky
Copy link
Contributor

bertsky commented Mar 28, 2022

This brings me back to the idea, that ocrd-kraken-segment should learn "Regions-level". And with this lines, the dewarping should work ok.
What do you think?

You mean the line-level dewarping? Yes, I guess it would be better, but for extreme cases like this, the Ocropy dewarper currently is not working well – it only follows a certain amount of slope. (You'll probably have to set -P smoothness 0.1 or so.) In the future, it will directly follow the annotated polygon (or even baseline), instead of detecting the centerline via the old lineest mechanism.

But to get good textlines, even in the presence of high line warp, for print you can also use ocrd-cis-ocropy-segment on region level.

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

3 participants