Esempio n. 1
0
    def __init__(self, ckpt_path=None, gpu='0'):
        print('Classifier_Vietocr. Init')
        self.config = Cfg.load_config(cls_base_config_path, cls_config_path)

        if ckpt_path is not None:
            self.config['weights'] = ckpt_path
        self.config['cnn']['pretrained'] = False
        if gpu is not None:
            self.config['device'] = 'cuda:' + str(gpu)
        else:
            self.config['device'] = 'cpu'
        self.config['predictor']['beamsearch'] = False
        self.model = Predictor(self.config)
Esempio n. 2
0
 def __init__(self):
     self.yolo = YOLOv4()
     self.yolo.classes = './coco.names'
     self.yolo.make_model()
     self.yolo.load_weights("./model/yolov4-custom_last.weights",
                            weights_type="yolo")
     self.config = Cfg.load_config()
     self.config['weights'] = './model/transformerocr.pth'
     self.config['predictor']['beamsearch'] = False
     self.config['device'] = 'cpu'
     self.detector = Predictor(self.config)
     self.classes = ['id', 'name', 'dmy', 'add1', 'add2']
     self.res = dict.fromkeys(self.classes, '')