MCPcopy
hub / github.com/JaidedAI/EasyOCR / get_detector

Function get_detector

easyocr/detection.py:74–90  ·  view source on GitHub ↗
(trained_model, device='cpu', quantize=True, cudnn_benchmark=False)

Source from the content-addressed store, hash-verified

72 return boxes_list, polys_list
73
74def get_detector(trained_model, device='cpu', quantize=True, cudnn_benchmark=False):
75 net = CRAFT()
76
77 if device == 'cpu':
78 net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device, weights_only=False)))
79 if quantize:
80 try:
81 torch.quantization.quantize_dynamic(net, dtype=torch.qint8, inplace=True)
82 except:
83 pass
84 else:
85 net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device, weights_only=False)))
86 net = torch.nn.DataParallel(net).to(device)
87 cudnn.benchmark = cudnn_benchmark
88
89 net.eval()
90 return net
91
92def get_textbox(detector, image, canvas_size, mag_ratio, text_threshold, link_threshold, low_text, poly, device, optimal_num_chars=None, **kwargs):
93 result = []

Callers

nothing calls this directly

Calls 3

loadMethod · 0.80
CRAFTClass · 0.70
copyStateDictFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…