(trained_model, device='cpu', quantize=True, cudnn_benchmark=False)
| 72 | return boxes_list, polys_list |
| 73 | |
| 74 | def 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 | |
| 92 | def get_textbox(detector, image, canvas_size, mag_ratio, text_threshold, link_threshold, low_text, poly, device, optimal_num_chars=None, **kwargs): |
| 93 | result = [] |
nothing calls this directly
no test coverage detected
searching dependent graphs…