Packaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector
Full Changelog: https://github.com/fcakyon/craft-text-detector/compare/0.4.2...0.4.3
Full Changelog: https://github.com/fcakyon/craft-text-detector/compare/0.4.1...0.4.2
Full Changelog: https://github.com/fcakyon/craft-text-detector/compare/0.4.0...0.4.1
from PIL import Image
import numpy
# can be filepath, PIL image or numpy array
image = 'figures/idcard.png'
image = Image.open("figures/idcard.png")
image = numpy.array(Image.open("figures/idcard.png"))
# apply craft text detection
prediction_result = craft.detect_text(image)
path for the weight file can be specified by:
load_craftnet_model(weight_path="path/to/weight")
load_refinenet_model(weight_path="path/to/weight")
# import Craft class
from craft_text_detector import Craft
# set image path and export folder directory
image_path = 'figures/idcard.png'
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_path)
# unload models from ram/gpu
craft.unload_craftnet_model()
craft.unload_refinenet_model()