sparkocr.utils.craft#
Subpackages#
Submodules#
Package Contents#
Classes#
Attributes#
- class Craft(output_dir=None, rectify=True, export_extra=True, text_threshold=0.7, link_threshold=0.4, low_text=0.4, cuda=False, long_size=1280, refiner=True, crop_type='poly', weight_path_craft_net: str | None = None, weight_path_refine_net: str | None = None)#
- craft_net = None#
- crop_type = 'poly'#
- cuda = False#
- export_extra = True#
- link_threshold = 0.4#
- long_size = 1280#
- low_text = 0.4#
- output_dir = None#
- rectify = True#
- refine_net = None#
- refiner = True#
- text_threshold = 0.7#
- detect_text(image, image_path=None)#
- Parameters:
image – path to the image to be processed or numpy array or PIL image
- Output:
- {
“masks”: lists of predicted masks 2d as bool array, “boxes”: list of coords of points of predicted boxes, “boxes_as_ratios”: list of coords of points of predicted boxes as ratios of image size, “polys_as_ratios”: list of coords of points of predicted polys as ratios of image size, “heatmaps”: visualization of the detected characters/links, “text_crop_paths”: list of paths of the exported text boxes/polys, “times”: elapsed times of the sub modules, in seconds
}
- load_craftnet_model(weight_path: str | None = None)#
Loads craftnet model
- load_refinenet_model(weight_path: str | None = None)#
Loads refinenet model
- unload_craftnet_model()#
Unloads craftnet model
- unload_refinenet_model()#
Unloads refinenet model
- empty_cuda_cache#
- export_detected_regions#
- export_extra_results#
- get_prediction#
- load_craftnet_model#
- load_refinenet_model#
- read_image#