diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..32030ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,209 @@ +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk \ No newline at end of file diff --git a/README.md b/README.md index 6fa1509..d9603e8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,33 @@ -# sign-and-scan +# Pipeline: sign-and-scan -3 \ No newline at end of file +## Overview + +Sign and scan a PDF file without actually having to print out the PDF (or scan it). + +## How to use + +1. Prerequisites + +If you're on Debian (Ubuntu) Linux: + +```shell +$ apt install imagemagick +$ pip3 install towhee +``` + +If you're on MacOS: + +```shell +% brew install imagemagick +% pip3 install towhee +``` + +2. Run it + +```python +>>> from towhee import pipeline +>>> p = pipeline('fzliu/sign-and-scan') +>>> p('/path/to/lease.pdf', '/path/to/output.pdf', '/path/to/signature/file.jpg', x_offset, y_offset) +``` + +Enjoy! diff --git a/sign_and_scan.yaml b/sign_and_scan.yaml new file mode 100644 index 0000000..9f32d59 --- /dev/null +++ b/sign_and_scan.yaml @@ -0,0 +1,190 @@ +name: 'sign-and-scan' +operators: + - + name: '_start_op' + function: '_start_op' + init_args: + inputs: + - + df: '_start_df' + name: 'doc_path' + col: 0 + - + df: '_start_df' + name: 'out_path' + col: 1 + - + df: '_start_df' + name: 'sig_path' + col: 2 + - + df: '_start_df' + name: 'x_off' + col: 3 + - + df: '_start_df' + name: 'y_off' + col: 4 + outputs: + - + df: 'inputs' + iter_info: + type: map + - + name: 'compute_sig_feats' + function: 'fzliu/opencv-sift' + tag: 'main' + init_args: + contrast_thresh: '0.1' + inputs: + - + df: 'inputs' + name: 'sig_path' + col: 0 + outputs: + - + df: 'sig_img_kps' + iter_info: + type: map + - + name: 'compute_signature_kps' + function: 'fzliu/opencv-sift' + tag: 'main' + init_args: + contrast_thresh: '0.1' + inputs: + - + df: 'inputs' + name: 'path' + col: 3 + outputs: + - + df: 'sig_img_kps' + iter_info: + type: map + - + name: 'crop_signature_from_keypoints' + function: 'fzliu/crop-signature-from-keypoints' + tag: 'main' + init_args: + inputs: + - + df: 'inputs' + name: 'path' + col: 3 + - + df: 'sig_img_kps' + name: 'feats' + col: 0 + outputs: + - + df: 'sig_img_crop' + iter_info: + type: map + - + name: 'emulate_sign_and_scan' + function: 'fzliu/emulate-sign-and-scan' + tag: 'main' + init_args: + inputs: + - + df: 'inputs' + name: 'doc_path' + col: 0 + - + df: 'inputs' + name: 'out_path' + col: 1 + - + df: 'sig_img_crop' + name: '' + col: 0 + - + df: 'inputs' + name: 'x_off' + col: 3 + - + df: 'inputs' + name: 'y_off' + col: 4 + + outputs: + - + df: 'out_path' + iter_info: + type: map + - + name: '_end_op' + function: '_end_op' + init_args: + inputs: + - + df: 'out_path' + name: 'out_path' + col: 0 + outputs: + - + df: '_end_df' + iter_info: + type: map +dataframes: + - + name: '_start_df' + columns: + - + name: 'doc_path' + vtype: 'str' + - + name: 'out_path' + vtype: 'str' + - + name: 'sig_path' + vtype: 'str' + - + name: 'x_off' + vtype: 'int' + - + name: 'y_off' + vtype: 'int' + - + name: 'inputs' + columns: + - + name: 'doc_path' + vtype: 'str' + - + name: 'out_path' + vtype: 'str' + - + name: 'sig_path' + vtype: 'str' + - + name: 'x_off' + vtype: 'int' + - + name: 'y_off' + vtype: 'int' + - + name: 'sig_img_kps' + columns: + - + name: 'kps' + vtype: 'list' + - + name: 'sig_img_crop' + columns: + - + name: 'sig_img' + vtype: 'towhee.types.Image' + - + name: 'out_path' + columns: + - + name: 'out_path' + vtype: 'str' + - + name: '_end_df' + columns: + - + name: 'out_path' + vtype: 'str'