【问题标题】:getting TypeError: 'TextDetector' object is not callable获取 TypeError:'TextDetector' 对象不可调用
【发布时间】:2021-12-26 01:10:07
【问题描述】:

我的 TextDetector 对象是一个类的蓝图,但仍然无法调用它。 它以前可以工作,但现在无法正常工作。不知道为什么会这样。你们谁能给我这个 TypeError 的原因吗?

导入 predict_det

#from predict_det import TextDetector

导入 cv2

#import 火炬

#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)


TypeError Traceback(最近一次调用最后一次) ~\AppData\Local\Temp/ipykernel_3160/1748103168.py 在 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' 对象不可调用

【问题讨论】:

    标签: python callable-object paddle-paddle


    【解决方案1】:

    您没有为 TextDetector 构造函数传递任何参数,因此 det_algorithm 为“空”,这会引发错误:

        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
    

    【讨论】:

    • 我已经尝试为 TextDetector 传递 arg ,仍然得到同样的错误
    • 你传递了什么作为参数?
    • 我通过了图像和字典。 args = Utility.param_args() text_detector = predict_det.TextDetector(args) dt_boxes, elapse = text_detector(img)
    • 当我试图运行这个命令 (print(callable(text_detector))) 输出是 FALSE 来...我的 TextDetector 文件有问题但不知道是什么。我正在尝试以“call”方法运行它
    • 发现了问题,我的“call”方法在“init”方法中,因此出现了错误
    猜你喜欢
    • 1970-01-01
    • 2018-03-27
    • 2019-04-29
    • 2021-03-31
    • 1970-01-01
    • 2015-11-11
    • 2018-12-25
    • 2021-04-15
    • 2011-10-01
    相关资源
    最近更新 更多