from crafter import Crafter
crafter = Crafter()
prediction = crafter('test.png')
#for p1, p2, p3, p4 in prediction['boxes']:
# print(p1, p2, p3, p4)
print(prediction['times'])
{'resize_time': 0.1297764778137207, 'preprocessing_time': 0.07541060447692871, 'craftnet_time': 26.2554190158844, 'refinenet_time': 9.416042804718018, 'postprocess_time': 0.18222427368164062}
total time (h:min:sec): 0:00:36.063
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 = 'test.png'
output_dir = 'outputs/'
# read image
image = read_image(image)
# load models
refine_net = load_refinenet_model(cuda=False)
craft_net = load_craftnet_model(cuda=False)
# 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=False,
long_size=700 #1280
)
# export detected text regions
exported_file_paths = export_detected_regions(
image=image,
regions=prediction_result["boxes"],
output_dir=output_dir,
rectify=True
)
dont know why crafter time exceeded classic craft_text_detector ? may be i missed something ? how to check i use .onnx model ?
Traceback (most recent call last):
File "/home/pi/crafter/convert/craftnet.py", line 52, in <module>
craftnet_to_onnx(craftnet, "crafter/resources/craftnet.onnx")
File "/home/pi/crafter/convert/craftnet.py", line 47, in craftnet_to_onnx
np.testing.assert_allclose(feature.numpy(), ort_outs[1], rtol=1e-03, atol=1e-05)
File "/home/pi/.local/lib/python3.9/site-packages/numpy/testing/_private/utils.py", line 1527, in assert_allclose
assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
File "/home/pi/.local/lib/python3.9/site-packages/numpy/testing/_private/utils.py", line 844, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=0.001, atol=1e-05
Mismatched elements: 1 / 609280 (0.000164%)
Max absolute difference: 1.9073486e-05
Max relative difference: 0.05192127
x: array([[[[0.000000e+00, 0.000000e+00, 0.000000e+00, ..., 0.000000e+00,
0.000000e+00, 0.000000e+00],
[0.000000e+00, 0.000000e+00, 0.000000e+00, ..., 0.000000e+00,...
y: array([[[[0.000000e+00, 0.000000e+00, 0.000000e+00, ..., 0.000000e+00,
0.000000e+00, 0.000000e+00],
[0.000000e+00, 0.000000e+00, 0.000000e+00, ..., 0.000000e+00,...