# Docuwarp
Docuwarp is a Python library for unwarping documents. It uses for inference the model from the paper "UVDoc: Neural Grid-based Document Unwarping." For more information about the paper behind this model, you can read the paper [here](https://igl.ethz.ch/projects/uvdoc). The GitHub repository maintained by the author is available [here](https://github.com/tanguymagne/UVDoc/tree/main).
## Installation
To install Docuwarp, follow these steps:
For cpu
```bash
pip install "docuwarp[cpu]"
```
For cuda 11.X
```bash
pip install "docuwarp[gpu]"
```
For cuda 12.X
```bash
pip install "docuwarp[gpu]" --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/
```
## Usage
### Command Line Interface
You can use Docuwarp from the command line by providing an image file:
```bash
docuwarp examples/1.jpg
```
### Using in Code
You can also incorporate Docuwarp into your Python code as follows:
```python
from PIL import Image
from docuwarp.unwarp import Unwarp
unwarp = Unwarp()
image = Image.open('examples/1.jpg')
unwarped_image = unwarp.inference(image)
```
If you want to use CUDA:
```python
from PIL import Image
from docuwarp.unwarp import Unwarp
unwarp = Unwarp(providers=["CUDAExecutionProvider"])
image = Image.open('examples/1.jpg')
unwarped_image = unwarp.inference(image)
```
Check all execution providers [here](https://onnxruntime.ai/docs/execution-providers/).
### Example
<table>
<thead>
<tr>
<td>original</td>
<td>unwarp</td>
</tr>
</thead>
<tbody>
<tr>
<td><img src="https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/1.jpg" width="256" /></td>
<td><img src="https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/1_unwarp.jpg" width="256" /></td>
</tr>
<tr>
<td><img src="https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/2.jpg" width="256" /></td>
<td><img src="https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/2_unwarp.jpg" width="256" /></td>
</tr>
</tbody>
</table>
## Citation
```
@inproceedings{UVDoc,
title={{UVDoc}: Neural Grid-based Document Unwarping},
author={Floor Verhoeven and Tanguy Magne and Olga Sorkine-Hornung},
booktitle = {SIGGRAPH ASIA, Technical Papers},
year = {2023},
url={https://doi.org/10.1145/3610548.3618174}
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/pstwh/docuwarp",
"name": "docuwarp",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.5",
"maintainer_email": null,
"keywords": "document, unwarp, photo",
"author": null,
"author_email": null,
"download_url": null,
"platform": null,
"description": "\n# Docuwarp\n\nDocuwarp is a Python library for unwarping documents. It uses for inference the model from the paper \"UVDoc: Neural Grid-based Document Unwarping.\" For more information about the paper behind this model, you can read the paper [here](https://igl.ethz.ch/projects/uvdoc). The GitHub repository maintained by the author is available [here](https://github.com/tanguymagne/UVDoc/tree/main).\n\n\n## Installation\n\nTo install Docuwarp, follow these steps:\n\nFor cpu\n\n```bash\npip install \"docuwarp[cpu]\"\n```\n\nFor cuda 11.X\n```bash\npip install \"docuwarp[gpu]\"\n```\n\nFor cuda 12.X\n```bash\npip install \"docuwarp[gpu]\" --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/\n```\n\n## Usage\n\n### Command Line Interface\n\nYou can use Docuwarp from the command line by providing an image file:\n\n```bash\ndocuwarp examples/1.jpg\n```\n\n### Using in Code\n\nYou can also incorporate Docuwarp into your Python code as follows:\n\n```python\nfrom PIL import Image\nfrom docuwarp.unwarp import Unwarp\n\nunwarp = Unwarp()\nimage = Image.open('examples/1.jpg')\nunwarped_image = unwarp.inference(image)\n```\n\nIf you want to use CUDA:\n```python\nfrom PIL import Image\nfrom docuwarp.unwarp import Unwarp\n\nunwarp = Unwarp(providers=[\"CUDAExecutionProvider\"])\nimage = Image.open('examples/1.jpg')\nunwarped_image = unwarp.inference(image)\n```\n\nCheck all execution providers [here](https://onnxruntime.ai/docs/execution-providers/).\n\n### Example\n\n<table>\n <thead>\n <tr>\n <td>original</td>\n <td>unwarp</td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><img src=\"https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/1.jpg\" width=\"256\" /></td>\n <td><img src=\"https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/1_unwarp.jpg\" width=\"256\" /></td>\n </tr>\n <tr>\n <td><img src=\"https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/2.jpg\" width=\"256\" /></td>\n <td><img src=\"https://raw.githubusercontent.com/pstwh/docuwarp/main/examples/2_unwarp.jpg\" width=\"256\" /></td>\n </tr>\n </tbody>\n</table>\n\n\n## Citation\n\n```\n@inproceedings{UVDoc,\ntitle={{UVDoc}: Neural Grid-based Document Unwarping},\nauthor={Floor Verhoeven and Tanguy Magne and Olga Sorkine-Hornung},\nbooktitle = {SIGGRAPH ASIA, Technical Papers},\nyear = {2023},\nurl={https://doi.org/10.1145/3610548.3618174}\n}\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Unwarp documents",
"version": "1.0.2",
"project_urls": {
"Homepage": "https://github.com/pstwh/docuwarp"
},
"split_keywords": [
"document",
" unwarp",
" photo"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bc33d8e2eb0474df899c634a04251eb36a903af07ea4869b2885731f8b4ea016",
"md5": "9317361717e74ec3cbf5404fcc6bb634",
"sha256": "da0d3838bb13b2fcf768919af94a0f1354321ae0a49e774cf5dde9f65bc0a5e9"
},
"downloads": -1,
"filename": "docuwarp-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9317361717e74ec3cbf5404fcc6bb634",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.5",
"size": 14818901,
"upload_time": "2024-07-15T01:04:37",
"upload_time_iso_8601": "2024-07-15T01:04:37.602453Z",
"url": "https://files.pythonhosted.org/packages/bc/33/d8e2eb0474df899c634a04251eb36a903af07ea4869b2885731f8b4ea016/docuwarp-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-15 01:04:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pstwh",
"github_project": "docuwarp",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "docuwarp"
}