timestamp = time.strftime('_%m%d%H%M%S', time.localtime()) output_dir = './test_result/test_result' + timestamp check_output_dir(output_dir) test_data = './test' list_dir = os.listdir(test_data) for target in list_dir: # read one image imagePath = os.path.join(test_data, target) print(imagePath) image = cv2.imread(imagePath) success, local = face_detection(image) if success: local = box_reduce(local, 30) img_32 = image_pre_processing(image, local) result, guess = img_test(model, img_32) # predict pd_result_name = map_characters[result] print('index:', result) print('name:', pd_result_name) cv2.rectangle(image, (local[0], local[1]), (local[2], local[3]), (0, 255, 0), 4, cv2.LINE_AA) cv2.putText(image, pd_result_name, (local[0], local[1] - 8), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 2, cv2.LINE_AA) timestamp = str(int(round(time.time() * 1000))) cv2.imwrite(output_dir + '/' + str(guess) + '_' + str(target),
# write predict result name pd_result_name = '' count_list = [0] * len(anchor_name) ### while videoIn.isOpened(): # read video from camera ret, outframe = videoIn.read() if (ret): # keyboard input value key = cv2.waitKey(1) & 0xFF success, local = face_detection(outframe) if success: local = box_reduce(local) img_32 = image_pre_processing(outframe, local) #--------------- predict ---------------- img_32_np = np.array(img_32, dtype='float32') img_32_np = img_32_np[np.newaxis, np.newaxis, :, :] / 255.0 img_feature = fix_model.predict(img_32_np) img_feature = img_feature[np.newaxis, :, :, :, :] fix_feature_repeat = np.repeat(fix_feature, img_feature.shape[1], axis=0) img_feature_repeat = np.repeat(img_feature, fix_feature.shape[1],