def __init__(self, config_path=None, weight_path=None, model_name=None):
    if (config_path is None):
        config_path = 'tool/config/ocr/configs.yaml'
    config = Config(config_path)
    ocr_config = ocr.Config.load_config_from_name(config.model_name)
    ocr_config['cnn']['pretrained'] = False
    ocr_config['device'] = 'cuda:0'
    ocr_config['predictor']['beamsearch'] = False
    self.model_name = model_name
    if (weight_path is None):
        if (self.model_name is None):
            self.model_name = 'transformerocr_default_vgg'
        tmp_path = os.path.join(CACHE_DIR, f'{self.model_name}.pth')
        download_pretrained_weights(self.model_name, cached=tmp_path)
        weight_path = tmp_path
    ocr_config['weights'] = weight_path
    self.model = ocr.Predictor(ocr_config)
def __init__(self, config_path=None, weight_path=None, model_name=None):
    if (config_path is None):
        config_path = 'tool/config/ocr/configs.yaml'
    config = Config(config_path)
    ocr_config = ocr.Config.load_config_from_name(config.model_name)
    ocr_config['cnn']['pretrained'] = False
    ocr_config['device'] = 'cuda:0'
    ocr_config['predictor']['beamsearch'] = False
    self.model_name = model_name
    if (weight_path is None):
        if (self.model_name is None):
            self.model_name = 'transformerocr_default_vgg'
        tmp_path = os.path.join(CACHE_DIR, f'{self.model_name}.pth')
        download_pretrained_weights(self.model_name, cached=tmp_path)
        weight_path = tmp_path
    ocr_config['weights'] = weight_path
    self.model = ocr.Predictor(ocr_config)