import body import ip_preprocessing as pre import ip_draw as draw import file_utils as file from CONFIG import Config from MODEL import CNN import cv2 import time import glob from os.path import join as pyjoin # initialization C = Config() C.build_output_folders(False) input_root = C.ROOT_INPUT input_paths = glob.glob(pyjoin(input_root, '*.png')) input_paths = sorted(input_paths, key=lambda x: int(x.split('\\')[-1][:-4])) # sorted by index def save(index, org, binary, corners_block, corners_img, corners_compo, compos_class, corners_text): out_img_gradient = pyjoin(C.ROOT_IMG_GRADIENT, index + '.png') out_img_draw = pyjoin(C.ROOT_IMG_DRAWN, index + '.png') out_img_clean = pyjoin(C.ROOT_IMG_CLEAN, index + '.png') out_label = pyjoin(C.ROOT_LABEL, index + '.json') # *** Step 7 *** post-processing: remove img elements from original image and segment into smaller size img_clean = draw.draw_bounding_box(org, corners_img, color=(255, 255, 255), line=-1) # draw results draw_bounding = draw.draw_bounding_box_class(org, corners_compo, compos_class)
import time import ocr_east as ocr import ip import merge from CONFIG import Config # choose functionality is_ocr = True is_ip = True is_merge = True # initialization is_clip = False C = Config() C.build_output_folders(is_clip) resize_by_height = 600 # set input root directory and sort all images by their indices input_paths_img = glob.glob(pjoin(C.ROOT_INPUT, '*.jpg')) input_paths_img = sorted( input_paths_img, key=lambda x: int(x.split('\\')[-1][:-4])) # sorted by index # set the range of target inputs' indices start_index = 24 end_index = 50 for input_path_img in input_paths_img: index = input_path_img.split('\\')[-1][:-4] if int(index) < start_index: continue if int(index) > end_index:
import glob from os.path import join as pyjoin # choose functionality is_merge_img = True is_shrink_img = True is_detect_compo_in_img = True is_classify = True is_ocr = True is_segment = False is_save = True is_clip = False # initialization C = Config() C.build_output_folders(is_segment) input_root = C.ROOT_INPUT input_paths = glob.glob(pyjoin(input_root, '*.png')) input_paths = sorted( input_paths, key=lambda x: int(x.split('\\')[-1][:-4])) # sorted by index CNN = CNN() CNN.load() # start image and end image start_index = 20 end_index = 100 for input_path in input_paths: index = input_path.split('\\')[-1][:-4] if int(index) < start_index: continue