简体   繁体   中英

getting TypeError: 'TextDetector' object is not callable

My TextDetector object is a blueprint of a class but still not able to call it. it was working before but now it is not working. Don't know why it happened. Can anyone of you give me a reason for this TypeError?

import predict_det

#from predict_det import TextDetector

import cv2

#import torch

#device = torch.device('cuda:0')

text_detector = predict_det.TextDetector()

img = cv2.imread(r'C:\\Users\\pearl\\Downloads\\AI\\Project OCR\\OCR_PP_tester\\Temp_img_folder\\images.jpg')

dt_boxes, elapse = text_detector(img)

<class 'list'>


TypeError Traceback (most recent call last) ~\\AppData\\Local\\Temp/ipykernel_3160/1748103168.py in 7 text_detector = predict_det.TextDetector() 8 img = cv2.imread(r'C:\\Users\\pearl\\Downloads\\AI\\Project OCR\\OCR_PP_tester\\Temp_img_folder\\images.jpg') ----> 9 dt_boxes, elapse = text_detector(img)

TypeError: 'TextDetector' object is not callable

Could you share your predict_det.py , or at least the TextDetector class? That would be helpful in answering your question! Thanks.

You are not passing any arg for the TextDetector constructor, thus det_algorithm is 'empty' which raises an error:

    if self.det_algorithm == "EAST":
        preds['f_geo'] = outputs[0]
        preds['f_score'] = outputs[1]
    elif self.det_algorithm == 'SAST':
        preds['f_border'] = outputs[0]
        preds['f_score'] = outputs[1]
        preds['f_tco'] = outputs[2]
        preds['f_tvo'] = outputs[3]
    elif self.det_algorithm == 'DB':
        preds['maps'] = outputs[0]
    else:
        raise NotImplementedError

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM