add warmup

This commit is contained in:
LDOUBLEV 2021-06-09 13:27:13 +08:00
parent 2c2918f27a
commit 1de1f30a97
4 changed files with 19 additions and 0 deletions

View File

@ -202,6 +202,12 @@ if __name__ == "__main__":
count = 0
total_time = 0
draw_img_save = "./inference_results"
# warmup 10 times
if args.warmup:
img = np.random.uniform(0, 255, [640, 640, 3]).astype(np.uint8)
for i in range(10):
res = text_detector(img)
if not os.path.exists(draw_img_save):
os.makedirs(draw_img_save)
for image_file in image_file_list:

View File

@ -254,6 +254,12 @@ def main(args):
total_images_num = 0
valid_image_file_list = []
img_list = []
# warmup 10 times
if args.warmup:
img = np.random.uniform(0, 255, [32, 320, 3]).astype(np.uint8)
for i in range(10):
res = text_recognizer([img])
for idx, image_file in enumerate(image_file_list):
img, flag = check_and_read_gif(image_file)
if not flag:

View File

@ -147,6 +147,12 @@ def main(args):
is_visualize = True
font_path = args.vis_font_path
drop_score = args.drop_score
# warm up 10 times
if args.warmup:
img = np.random.uniform(0, 255, [640, 640, 3]).astype(np.uint8)
for i in range(10):
res = text_sys(img)
for image_file in image_file_list:
img, flag = check_and_read_gif(image_file)
if not flag:

View File

@ -105,6 +105,7 @@ def init_args():
parser.add_argument("--enable_mkldnn", type=str2bool, default=False)
parser.add_argument("--cpu_threads", type=int, default=10)
parser.add_argument("--use_pdserving", type=str2bool, default=False)
parser.add_argument("--warmup", type=str2bool, default=True)
parser.add_argument("--use_mp", type=str2bool, default=False)
parser.add_argument("--total_process_num", type=int, default=1)