def init(): # Init all variable global fs, fd, today_dir, index, img_path_map fs = FaceSearcher(**cfg.search_config) fd = FaceDetector(**cfg.detect_config) # Make folder today_dir = init_folder(cfg.data_path, cfg.wards) # If data exist ==> add them to graph w_paths = [os.path.join(today_dir, w, 'true') for w in cfg.wards] features = [] for w_path in w_paths: for image_name in os.listdir(w_path): image_path = os.path.join(w_path, image_name) # Add path to path map img_path_map.append(image_path) # convert image to pytorch tensor image = pil_loader(image_path) image = ToTensor()(image) # extract all tensor = fd.extract_feature(image) # print(tensor.shape) features.append(tensor) index += 1 # Add to graph print('Getting {} images'.format(index)) if index > 0: features = np.array(features) # print(features.shape) fs.add_faces(features, np.arange(index))