Skip to main content

Document segmentation.

Project description

midv-500-models

The repository contains a model for binary semantic segmentation of the documents.

  • Left: input.
  • Center: prediction.
  • Right: overlay of the image and predicted mask.

Installation

pip install -U midv500models

For more details: Example notebook

Dataset

Model is trained on MIDV-500: A Dataset for Identity Documents Analysis and Recognition on Mobile Devices in Video Stream.

Preparation

Download the dataset from the ftp server with

wget -r ftp://smartengines.com/midv-500/

Unpack the dataset

cd smartengines.com/midv-500/dataset/
unzip \*.zip

The resulting folder structure will be

smartengines.com
    midv-500
        dataset
            01_alb_id
                ground_truth
                    CA
                        CA01_01.tif
                    ...
                images
                    CA
                        CA01_01.json
                    ...
                ...
            ...
        ...
    ...

To preprocess the data use the script

python midv500models/preprocess_data.py -i <input_folder> \
                                          -o <output_folder>

where input_folder corresponds to the file with the unpacked dataset and output folder will look as:

images
    CA01_01.jpg
    ...
masks
    CA01_01.png

target binary masks will have values [0, 255], where 0 is background and 255 is the document.

Training

python midv500models/train.py -c midv500models/configs/2020-05-19.yaml \
                              -i <path to train>

Inference

python midv500models/inference.py -c midv500models/configs/2020-05-19.yaml \
                                  -i <path to images> \
                                  -o <path to save preidctions>
                                  -w <path to weights>

Example notebook

Example notebook

Weights

Unet with Resnet34 backbone: Config Weights

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midv500models-0.0.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

midv500models-0.0.2-py2.py3-none-any.whl (11.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file midv500models-0.0.2.tar.gz.

File metadata

  • Download URL: midv500models-0.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.3

File hashes

Hashes for midv500models-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6f315800d64a54bea9095b23e9d6da70c7c698d0973637e0be9fc0a3f10f2bb4
MD5 7c2432b006b061eb5e39f01ca4dc7ecf
BLAKE2b-256 fb17ae70bf3aacbb6f028c91946b24c181061f072a4a88a7b9efa748d5a7a1a9

See more details on using hashes here.

File details

Details for the file midv500models-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: midv500models-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.3

File hashes

Hashes for midv500models-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 af01509ce2d119ec6e08c052748b284cd4f1f1d64cdca831cef779a49dbef016
MD5 a2dcfbbd2c6de820d5023410133cba28
BLAKE2b-256 ca2f66d12db9daa6f7d72f33a576f07999d40a409a253b3913199d145e9fc338

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page