Skip to main content

A modern version of CRAFT-pytorch using the latest versions

Project description

Modern CRAFT Library

Overview

This Python library provides an interface for using the CRAFT (Character Region Awareness For Text Detection) algorithm for text detection in images. The library is based on the CRAFT implementation in Python.

This is an adaptation of the CRAFT-python library allowing for use on modern packages (pytorch 2 > opencv-python > 3.4).

GPU (CUDA) Acceleration has now been tested.

ToDo

This library will need refactoring with respect to performance as the previous library introduced unneeded overhead.

Requirements

  • Python 3.x
  • PyTorch
  • OpenCV
  • NumPy

Installation

You can install the library via pip:

pip install mcraft

Usage

    from mcraft import TNet
    
    # Load an image
    image_path = "path/to/your/image.jpg"
    
    # Initialize the network
    tnet = TNet()  # Adjust parameters as needed
    
    # Run a test
    tnet.test(image_path)
    
    # Perform text detection
    tnet.test(image_path)
    
    # After running test, the result will be saved as "res_image_mask.jpg" in the same directory as the input image

res_cover_mask

Features

  • Text detection in images produced as heat-maps bounding boxes and per-character polygons.
  • Adjustable parameters such as text threshold, link threshold, etc.

Important Notes

  • Preexisting or hand compiled instances of opencv, pytorch, and torchvision will not be replaced during setup.
  • The necessary model files (craft_mlt_25k.pth and craft_refiner_CTW1500.pth) will be downloaded to ~/.cache/mcraft.
  • GPU operations, whilst implemented, remain untested until I get back from abroad and regain access to my compute systems.
  • Official CRAFT PyTorch repository

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

mcraft-0.0.4a0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

mcraft-0.0.4a0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file mcraft-0.0.4a0.tar.gz.

File metadata

  • Download URL: mcraft-0.0.4a0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for mcraft-0.0.4a0.tar.gz
Algorithm Hash digest
SHA256 7eee56863edaf03df7d4c2849dc90d51b8db5616dc0f497d01bc888783184296
MD5 5a76af526fb88f014a03f22d93f9f152
BLAKE2b-256 b8a6cea10ca26a7c1a64d09b7574878b6a2ee6f2c9d3239fbe9b741032a8631d

See more details on using hashes here.

File details

Details for the file mcraft-0.0.4a0-py3-none-any.whl.

File metadata

  • Download URL: mcraft-0.0.4a0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for mcraft-0.0.4a0-py3-none-any.whl
Algorithm Hash digest
SHA256 44336359483e8d833843e7740a832a2f25b631e93b994a27a8f907d77f27c4a0
MD5 e77a59d57827e705025deb2826a9e073
BLAKE2b-256 75917a02679659ae31bab3eec61dcbac0acddfbbcfe51746adb9a682b8cef86d

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