Spaces:
Running
Running
File size: 1,039 Bytes
0d6ddfa |
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 |
import argparse
from asyncio.log import logger
from Layoutlmv3_inference.ocr import prepare_batch_for_inference
from Layoutlmv3_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 + '/' + image_files[0]]
inference_batch = prepare_batch_for_inference(images_path)
context = {"model_dir": args.model_path}
handle(inference_batch,context)
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)
|