Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save detection inference logs to file #12042

Merged
merged 4 commits into from
May 29, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tools/infer/predict_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
from ppocr.postprocess import build_post_process
import json

logger = get_logger()


class TextDetector(object):
def __init__(self, args):
def __init__(self, args, logger):
AlexPasqua marked this conversation as resolved.
Show resolved Hide resolved
self.args = args
self.det_algorithm = args.det_algorithm
self.use_onnx = args.use_onnx
Expand Down Expand Up @@ -158,7 +156,7 @@ def __init__(self, args):
model_precision=args.precision,
batch_size=1,
data_shape="dynamic",
save_path=None,
save_path=None, # not used if logger is not None
inference_config=self.config,
pids=pid,
process_name=None,
Expand Down Expand Up @@ -383,11 +381,21 @@ def __call__(self, img):
if __name__ == "__main__":
args = utility.parse_args()
image_file_list = get_image_file_list(args.image_dir)
text_detector = TextDetector(args)
total_time = 0
draw_img_save_dir = args.draw_img_save_dir
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this logger should be prepared and passed into AutoLog as a arg in https://github.com/PaddlePaddle/PaddleOCR/blob/main/tools/infer/predict_det.py#L168

I am worrying about maintenance of AutoLog module, it's been implemented in https://github.com/LDOUBLEV/AutoLog, and published to a server as documented here:

${python_name} -m pip install https://paddleocr.bj.bcebos.com/libs/auto_log-1.2.0-py3-none-any.whl
.

I think this is only been used by a terminated tipc plan, we should redesign this feature, or deprecate this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worrying about maintenance of AutoLog module, it's been implemented in https://github.com/LDOUBLEV/AutoLog, and published to a server as documented here:

In this case PaddleOCR could implement its own logger, instead of using AutoLog.

I think that it's a little bit of a pity to have a feature to run benchmarks without the option to save the results to a file (and only seeing them on screen instead), therefore I think this feature would be very useful.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree


# create text detector
text_detector = TextDetector(args, logger)

if args.warmup:
img = np.random.uniform(0, 255, [640, 640, 3]).astype(np.uint8)
for i in range(2):
Expand Down
Loading