craft-text-detector-jsl


Namecraft-text-detector-jsl JSON
Version 0.4.3 PyPI version JSON
download
home_pagehttps://github.com/fcakyon/craft_text_detector
SummaryFast and accurate text detection library built on CRAFT implementation
upload_time2024-01-15 18:00:17
maintainer
docs_urlNone
authorFatih Cagatay Akyon
requires_python>=3.7
licenseMIT
keywords machine-learning deep-learning ml pytorch text text-detection craft
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CRAFT: Character-Region Awareness For Text detection

<p align="center">
<a href="https://pepy.tech/project/craft-text-detector"><img src="https://pepy.tech/badge/craft-text-detector" alt="downloads"></a>
<a href="https://pypi.org/project/craft-text-detector"><img src="https://img.shields.io/pypi/pyversions/craft-text-detector" alt="downloads"></a>
<a href="https://twitter.com/fcakyon"><img src="https://img.shields.io/twitter/follow/fcakyon?color=blue&logo=twitter&style=flat" alt="fcakyon twitter">
<br>
<a href="https://github.com/fcakyon/craft-text-detector/actions"><img alt="Build status" src="https://github.com/fcakyon/craft-text-detector/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://badge.fury.io/py/craft-text-detector"><img src="https://badge.fury.io/py/craft-text-detector.svg" alt="PyPI version" height="20"></a>
<a href="https://github.com/fcakyon/craft-text-detector/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/pypi/l/craft-text-detector"></a>
</p>

Packaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector | [Paper](https://arxiv.org/abs/1904.01941) |

## Overview

PyTorch implementation for CRAFT text detector that effectively detect text area by exploring each character region and affinity between characters. The bounding box of texts are obtained by simply finding minimum bounding rectangles on binary map after thresholding character region and affinity scores.

<img width="1000" alt="teaser" src="./figures/craft_example.gif">

## Getting started

### Installation

- Install using pip:

```console
pip install craft-text-detector
```

### Basic Usage

```python
# import Craft class
from craft_text_detector import Craft

# set image path and export folder directory
image = 'figures/idcard.png' # can be filepath, PIL image or numpy array
output_dir = 'outputs/'

# create a craft instance
craft = Craft(output_dir=output_dir, crop_type="poly", cuda=False)

# apply craft text detection and export detected regions to output directory
prediction_result = craft.detect_text(image)

# unload models from ram/gpu
craft.unload_craftnet_model()
craft.unload_refinenet_model()
```

### Advanced Usage

```python
# import craft functions
from craft_text_detector import (
    read_image,
    load_craftnet_model,
    load_refinenet_model,
    get_prediction,
    export_detected_regions,
    export_extra_results,
    empty_cuda_cache
)

# set image path and export folder directory
image = 'figures/idcard.png' # can be filepath, PIL image or numpy array
output_dir = 'outputs/'

# read image
image = read_image(image)

# load models
refine_net = load_refinenet_model(cuda=True)
craft_net = load_craftnet_model(cuda=True)

# perform prediction
prediction_result = get_prediction(
    image=image,
    craft_net=craft_net,
    refine_net=refine_net,
    text_threshold=0.7,
    link_threshold=0.4,
    low_text=0.4,
    cuda=True,
    long_size=1280
)

# export detected text regions
exported_file_paths = export_detected_regions(
    image=image,
    regions=prediction_result["boxes"],
    output_dir=output_dir,
    rectify=True
)

# export heatmap, detection points, box visualization
export_extra_results(
    image=image,
    regions=prediction_result["boxes"],
    heatmaps=prediction_result["heatmaps"],
    output_dir=output_dir
)

# unload models from gpu
empty_cuda_cache()
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fcakyon/craft_text_detector",
    "name": "craft-text-detector-jsl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "machine-learning,deep-learning,ml,pytorch,text,text-detection,craft",
    "author": "Fatih Cagatay Akyon",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/15/14/42d035b0349b26921b4e58480c8a2be888b38ac3e80219a4f2ed22a1281f/craft-text-detector-jsl-0.4.3.tar.gz",
    "platform": null,
    "description": "# CRAFT: Character-Region Awareness For Text detection\n\n<p align=\"center\">\n<a href=\"https://pepy.tech/project/craft-text-detector\"><img src=\"https://pepy.tech/badge/craft-text-detector\" alt=\"downloads\"></a>\n<a href=\"https://pypi.org/project/craft-text-detector\"><img src=\"https://img.shields.io/pypi/pyversions/craft-text-detector\" alt=\"downloads\"></a>\n<a href=\"https://twitter.com/fcakyon\"><img src=\"https://img.shields.io/twitter/follow/fcakyon?color=blue&logo=twitter&style=flat\" alt=\"fcakyon twitter\">\n<br>\n<a href=\"https://github.com/fcakyon/craft-text-detector/actions\"><img alt=\"Build status\" src=\"https://github.com/fcakyon/craft-text-detector/actions/workflows/ci.yml/badge.svg\"></a>\n<a href=\"https://badge.fury.io/py/craft-text-detector\"><img src=\"https://badge.fury.io/py/craft-text-detector.svg\" alt=\"PyPI version\" height=\"20\"></a>\n<a href=\"https://github.com/fcakyon/craft-text-detector/blob/main/LICENSE\"><img alt=\"License: MIT\" src=\"https://img.shields.io/pypi/l/craft-text-detector\"></a>\n</p>\n\nPackaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector | [Paper](https://arxiv.org/abs/1904.01941) |\n\n## Overview\n\nPyTorch implementation for CRAFT text detector that effectively detect text area by exploring each character region and affinity between characters. The bounding box of texts are obtained by simply finding minimum bounding rectangles on binary map after thresholding character region and affinity scores.\n\n<img width=\"1000\" alt=\"teaser\" src=\"./figures/craft_example.gif\">\n\n## Getting started\n\n### Installation\n\n- Install using pip:\n\n```console\npip install craft-text-detector\n```\n\n### Basic Usage\n\n```python\n# import Craft class\nfrom craft_text_detector import Craft\n\n# set image path and export folder directory\nimage = 'figures/idcard.png' # can be filepath, PIL image or numpy array\noutput_dir = 'outputs/'\n\n# create a craft instance\ncraft = Craft(output_dir=output_dir, crop_type=\"poly\", cuda=False)\n\n# apply craft text detection and export detected regions to output directory\nprediction_result = craft.detect_text(image)\n\n# unload models from ram/gpu\ncraft.unload_craftnet_model()\ncraft.unload_refinenet_model()\n```\n\n### Advanced Usage\n\n```python\n# import craft functions\nfrom craft_text_detector import (\n    read_image,\n    load_craftnet_model,\n    load_refinenet_model,\n    get_prediction,\n    export_detected_regions,\n    export_extra_results,\n    empty_cuda_cache\n)\n\n# set image path and export folder directory\nimage = 'figures/idcard.png' # can be filepath, PIL image or numpy array\noutput_dir = 'outputs/'\n\n# read image\nimage = read_image(image)\n\n# load models\nrefine_net = load_refinenet_model(cuda=True)\ncraft_net = load_craftnet_model(cuda=True)\n\n# perform prediction\nprediction_result = get_prediction(\n    image=image,\n    craft_net=craft_net,\n    refine_net=refine_net,\n    text_threshold=0.7,\n    link_threshold=0.4,\n    low_text=0.4,\n    cuda=True,\n    long_size=1280\n)\n\n# export detected text regions\nexported_file_paths = export_detected_regions(\n    image=image,\n    regions=prediction_result[\"boxes\"],\n    output_dir=output_dir,\n    rectify=True\n)\n\n# export heatmap, detection points, box visualization\nexport_extra_results(\n    image=image,\n    regions=prediction_result[\"boxes\"],\n    heatmaps=prediction_result[\"heatmaps\"],\n    output_dir=output_dir\n)\n\n# unload models from gpu\nempty_cuda_cache()\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fast and accurate text detection library built on CRAFT implementation",
    "version": "0.4.3",
    "project_urls": {
        "Homepage": "https://github.com/fcakyon/craft_text_detector"
    },
    "split_keywords": [
        "machine-learning",
        "deep-learning",
        "ml",
        "pytorch",
        "text",
        "text-detection",
        "craft"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6fc30bda14179529508cc061694570ab40fdb9e9b96f3baa9ea94e79821426e",
                "md5": "a22ff452835e4583cf4571e94ba632eb",
                "sha256": "bf5c810e51c6ed9f6436bd578814c563db2d668f24ffc0641aa56569966d7af7"
            },
            "downloads": -1,
            "filename": "craft_text_detector_jsl-0.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a22ff452835e4583cf4571e94ba632eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 18320,
            "upload_time": "2024-01-15T18:00:15",
            "upload_time_iso_8601": "2024-01-15T18:00:15.658070Z",
            "url": "https://files.pythonhosted.org/packages/d6/fc/30bda14179529508cc061694570ab40fdb9e9b96f3baa9ea94e79821426e/craft_text_detector_jsl-0.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "151442d035b0349b26921b4e58480c8a2be888b38ac3e80219a4f2ed22a1281f",
                "md5": "0fba542aef630855e3d8a6650cf44129",
                "sha256": "88d2c24c1d9a0f265c4423d426be792729221232c0fcee6775209764b29f2d0e"
            },
            "downloads": -1,
            "filename": "craft-text-detector-jsl-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0fba542aef630855e3d8a6650cf44129",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16311,
            "upload_time": "2024-01-15T18:00:17",
            "upload_time_iso_8601": "2024-01-15T18:00:17.433305Z",
            "url": "https://files.pythonhosted.org/packages/15/14/42d035b0349b26921b4e58480c8a2be888b38ac3e80219a4f2ed22a1281f/craft-text-detector-jsl-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-15 18:00:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fcakyon",
    "github_project": "craft_text_detector",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "craft-text-detector-jsl"
}
        
Elapsed time: 0.16005s