mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-26 21:24:27 +00:00
Save detection inference logs to file (#12042)
* Save detection inference logs to file * Minor fix on save_log_path * Formatted with black * If logger is None: get_logger()
This commit is contained in:
parent
92c59844f7
commit
6e7a1b871d
@ -32,11 +32,11 @@ from ppocr.data import create_operators, transform
|
|||||||
from ppocr.postprocess import build_post_process
|
from ppocr.postprocess import build_post_process
|
||||||
import json
|
import json
|
||||||
|
|
||||||
logger = get_logger()
|
|
||||||
|
|
||||||
|
|
||||||
class TextDetector(object):
|
class TextDetector(object):
|
||||||
def __init__(self, args):
|
def __init__(self, args, logger=None):
|
||||||
|
if logger is None:
|
||||||
|
logger = get_logger()
|
||||||
self.args = args
|
self.args = args
|
||||||
self.det_algorithm = args.det_algorithm
|
self.det_algorithm = args.det_algorithm
|
||||||
self.use_onnx = args.use_onnx
|
self.use_onnx = args.use_onnx
|
||||||
@ -158,7 +158,7 @@ class TextDetector(object):
|
|||||||
model_precision=args.precision,
|
model_precision=args.precision,
|
||||||
batch_size=1,
|
batch_size=1,
|
||||||
data_shape="dynamic",
|
data_shape="dynamic",
|
||||||
save_path=None,
|
save_path=None, # not used if logger is not None
|
||||||
inference_config=self.config,
|
inference_config=self.config,
|
||||||
pids=pid,
|
pids=pid,
|
||||||
process_name=None,
|
process_name=None,
|
||||||
@ -398,11 +398,21 @@ class TextDetector(object):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = utility.parse_args()
|
args = utility.parse_args()
|
||||||
image_file_list = get_image_file_list(args.image_dir)
|
image_file_list = get_image_file_list(args.image_dir)
|
||||||
text_detector = TextDetector(args)
|
|
||||||
total_time = 0
|
total_time = 0
|
||||||
draw_img_save_dir = args.draw_img_save_dir
|
draw_img_save_dir = args.draw_img_save_dir
|
||||||
os.makedirs(draw_img_save_dir, exist_ok=True)
|
os.makedirs(draw_img_save_dir, exist_ok=True)
|
||||||
|
|
||||||
|
# logger
|
||||||
|
log_file = args.save_log_path
|
||||||
|
if os.path.isdir(args.save_log_path) or (
|
||||||
|
not os.path.exists(args.save_log_path) and args.save_log_path.endswith("/")
|
||||||
|
):
|
||||||
|
log_file = os.path.join(log_file, "benchmark_detection.log")
|
||||||
|
logger = get_logger(log_file=log_file)
|
||||||
|
|
||||||
|
# create text detector
|
||||||
|
text_detector = TextDetector(args, logger)
|
||||||
|
|
||||||
if args.warmup:
|
if args.warmup:
|
||||||
img = np.random.uniform(0, 255, [640, 640, 3]).astype(np.uint8)
|
img = np.random.uniform(0, 255, [640, 640, 3]).astype(np.uint8)
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user