def __init__(self, original_path, result_path): super(MyWindow, self).__init__() uic.loadUi('eval_gui.ui', self) self.show() self.setWindowTitle("Evaluation") self.answers = [] # Load the list of images and shuffle them # Note: Make sure images match in each folder # i.e. they are in the same order in each dir paths_zipped = list( zip(files.get_images(original_path), files.get_images(result_path))) shuffle(paths_zipped) # shuffle the list of (original, result) paths original_paths, result_paths = zip( *paths_zipped) # Unzip into two different lists # Check if the number of images is the same if len(original_paths) != len(result_paths): print("Different num of images") sys.exit(0) # Dict to store each set of images self.img_paths = {"original": original_paths, "result": result_paths} # Make paths dynamic from CLI args self.fileNum = len(self.img_paths["original"]) self.fileCount = 0 print('Number of files: {}'.format(self.fileNum)) # Binding the buttons to functions self.correctButton.clicked.connect(lambda: self.correct_image()) self.nearButton.clicked.connect(lambda: self.near_image()) self.incorrectButton.clicked.connect(lambda: self.incorrect_image()) # Create the scenes for the 2D graphics viewers self.scenes = { "original": QtWidgets.QGraphicsScene(), "result": QtWidgets.QGraphicsScene() } # Bind the scenes to the correct objs self.original.setScene(self.scenes['original']) self.preprocessed.setScene(self.scenes['result']) # For each scene, draw the first image at th start for s_name, s_obj in self.scenes.items(): self.__set_scene_image(s_name, self.img_paths[s_name][0]) # Timing user input self.timeStart = time.process_time()
print("Root directory........ %s" % root_path) print("Output directory...... %s\n" % out_path) # Check that both directories exist if os.path.lexists(out_path) and os.path.lexists(root_path): pass else: print(Fore.RED + "Path not found, one of the directories does not exist.") print(Style.RESET_ALL) sys.exit(0) # Use system's abort function # Reset colour print(Style.RESET_ALL) images = files.get_images(root_path) # Note line below resets the blue print(Style.RESET_ALL + Fore.GREEN + "Number of images in the path: {:d}".format(len(images))) # Create the image matrix here height, width = 30, 30 img_matrix = np.zeros((len(images), height * width)) # (num_imgs x dim) # Going through all the images and polutating the img_matrix size = 20 # Length of the loading bar in chars for i, img_path in enumerate(images): # Open each image img = ut.read_image(img_path, "BGR2GRAY") resized = cv2.resize(img, (height, width), cv2.INTER_AREA)
# Reset colour print(Style.RESET_ALL) # Gather the data data = gather_data(eval_path) responses = gather_responses(data) response_times = gather_response_times(data) ########################################## ## Extracting the response images stuff ## ######################################### # Get all the images in the dataset image_paths = files.get_images(input_path) # Get the list of JUST the file names from all the images dataset_names = list(map(files.get_filename, image_paths)) # Get the response file names response_names = get_responsefiles(1, data) print("response is: {}".format(response_names)) # Make sure output path exists if not os.path.exists(output_path): os.mkdir(output_path) #mode = 777 # Loop to go trhough the response_times and copy the # images to the output directory for name in response_names: