File size: 1,093 Bytes
81e13bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import argparse
from asyncio.log import logger
from Layoutlm_inference.ocr import prepare_batch_for_inference
from Layoutlm_inference.inference_handler import handle
import logging
import os

if __name__ == "__main__":
    # try:
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_path", type=str)
    parser.add_argument("--images_path", type=str)
    args, _ = parser.parse_known_args()
    images_path = args.images_path
    image_files = os.listdir(images_path)
    images_path = [images_path+f'/{image_file}' for image_file in image_files]
    inference_batch = prepare_batch_for_inference(images_path)
    context = {"model_dir": args.model_path}
    output_ls = handle(inference_batch,context)
    
    print("output_ls",output_ls)
    
    
    # except Exception as err:
        # os.makedirs('log', exist_ok=True)
        # logging.basicConfig(filename='log/error_output.log', level=logging.ERROR,
        #                     format='%(asctime)s %(levelname)s %(name)s %(message)s')
        # logger = logging.getLogger(__name__)
        # logger.error(err)