def load_instances(input_filepath, output_filepath, symemtry_part_index): dirnames = glob.glob(input_filepath + '/*') instances = [] for dirname in dirnames: if not os.path.isdir(dirname): continue prefix = os.path.basename(dirname) print prefix is_loaded = True relative_image_filepath = [] image_filenames = [] image_filenames.append(prefix + '_view.png') image_filenames.append(prefix + '_input.png') image_filenames.append(prefix + '_symm_detection_recon.png') image_filenames.append(prefix + '_symm_detection_accuracy.png') image_filenames.append(prefix + '_symm_detection_completeness.png') # FIXME if not os.path.exists(dirname + '/../../output/' + prefix + '/' + prefix + '_input.png'): continue if not os.path.exists(dirname + '/../../output/' + prefix + '/' + prefix + '_view.png'): continue shutil.copy( dirname + '/../../output/' + prefix + '/' + prefix + '_input.png', dirname + '/' + prefix + '_input.png') shutil.copy( dirname + '/../../output/' + prefix + '/' + prefix + '_view.png', dirname + '/' + prefix + '_view.png') for image_filename in image_filenames: if not os.path.exists(dirname + '/' + image_filename): print 'Warning: File does not exist: "' + ( dirname + '/' + image_filename) + '"' is_loaded = False break if not os.path.exists(output_filepath + '/' + image_filename): # Copy the image. shutil.copy(dirname + '/' + image_filename, output_filepath) # Create a thumbnail. librr.create_thumbnails(output_filepath + '/' + image_filename, librr.thumbname_width) # Get relative file path. relative_image_filepath.append('./' + image_filename) if not is_loaded: continue accuracy_values = [] completeness_values = [] csv_filename_postfixes = [] csv_filename_postfixes.append('_symm_detection_recon') for csv_filename_postfix in csv_filename_postfixes: csv_filename = dirname + '/' + prefix + csv_filename_postfix + '.csv' if symemtry_part_index >= 0: # Real per-part files. csv_filename = dirname + '/' + prefix + csv_filename_postfix\ + '_' + str(symemtry_part_index) + '.csv' all_values = librr.get_csv_value(csv_filename, librr.threshold) if not all_values: accuracy_values.append(float("NaN")) completeness_values.append(float("NaN")) else: accuracy_values.append(all_values[0]) completeness_values.append(all_values[1]) instance = OutputInstance(prefix, relative_image_filepath[0], relative_image_filepath[1], relative_image_filepath[2], relative_image_filepath[3], relative_image_filepath[4], accuracy_values[0], completeness_values[0]) instances.append(instance) return instances
def load_instances(input_filepath, output_filepath, symemtry_part_index): dirnames = glob.glob(input_filepath + '/*') instances = [] for dirname in dirnames: if not os.path.isdir(dirname): continue prefix = os.path.basename(dirname) print prefix is_loaded = True candidate_index = librr.find_best_candidate(dirname, prefix) print('Candidate index: ' + str(candidate_index)) # Read images. relative_image_filepath = [] image_filenames = [] image_filenames.append(prefix + '_view.png') image_filenames.append(prefix + '_input.png') image_filenames.append(prefix + '_' + str(candidate_index) + '.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_symmetry_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_symmetry_completeness.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_database_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_database_completeness.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_fusion_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_fusion_completeness.png') for image_filename in image_filenames: if not os.path.exists(dirname + '/' + image_filename): print 'Warning: File does not exist: "' + ( dirname + '/' + image_filename) + '"' is_loaded = False break if not os.path.exists(output_filepath + '/' + image_filename): # Copy the image. shutil.copy(dirname + '/' + image_filename, output_filepath) # Create a thumbnail. librr.create_thumbnails(output_filepath + '/' + image_filename, librr.thumbname_width) # Get relative file path. relative_image_filepath.append('./' + image_filename) if not is_loaded: continue # Read stats. accuracy_values = [] completeness_values = [] csv_filename_postfixes = [] csv_filename_postfixes.append('_' + str(candidate_index) + '_symmetry') csv_filename_postfixes.append('_' + str(candidate_index) + '_database') csv_filename_postfixes.append('_' + str(candidate_index) + '_fusion') for csv_filename_postfix in csv_filename_postfixes: csv_filename = dirname + '/' + prefix + csv_filename_postfix + '.csv' if symemtry_part_index >= 0: # Read per-part files. csv_filename = dirname + '/' + prefix + csv_filename_postfix\ + '_' + str(symemtry_part_index) + '.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' is_loaded = False break else: all_values = librr.get_csv_value(csv_filename, librr.threshold) if not all_values: accuracy_values.append(float("NaN")) completeness_values.append(float("NaN")) else: accuracy_values.append(all_values[0]) completeness_values.append(all_values[1]) if not is_loaded: continue # Read per-point labeling accuracy. csv_filename = dirname + '/' + prefix + '_' + str( candidate_index) + '_labeling_stats.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' continue else: per_point_labeling_accuracy = read_value_from_csv_file( csv_filename, symemtry_part_index, 3) # Read cuboid distance to ground truth. csv_filename = dirname + '/' + prefix + '_' + str( candidate_index) + '_cuboid_distance.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' continue else: cuboid_distance_to_ground_truth = read_value_from_csv_file( csv_filename, symemtry_part_index, 1) instance = OutputInstance( prefix, relative_image_filepath[0], relative_image_filepath[1], relative_image_filepath[2], relative_image_filepath[3], relative_image_filepath[4], relative_image_filepath[5], relative_image_filepath[6], relative_image_filepath[7], relative_image_filepath[8], accuracy_values[0], completeness_values[0], accuracy_values[1], completeness_values[1], accuracy_values[2], completeness_values[2], per_point_labeling_accuracy, cuboid_distance_to_ground_truth) instances.append(instance) return instances
def load_instances(input_filepath, output_filepath, symemtry_part_index): dirnames = glob.glob(input_filepath + '/*') instances = [] for dirname in dirnames: if not os.path.isdir(dirname): continue prefix = os.path.basename(dirname) print prefix is_loaded = True relative_image_filepath = [] image_filenames = [] #image_filenames.append(prefix + '_view.png') #image_filenames.append(prefix + '_input.png') #image_filenames.append(prefix + '_symm_detection_recon.png') #image_filenames.append(prefix + '_symm_detection_accuracy.png') #image_filenames.append(prefix + '_symm_detection_completeness.png') for image_filename in image_filenames: if not os.path.exists(dirname + '/' + image_filename): print 'Warning: File does not exist: "' + (dirname + '/' + image_filename) + '"' is_loaded = False break if not os.path.exists(output_filepath + '/' + image_filename): # Copy the image. shutil.copy(dirname + '/' + image_filename, output_filepath) # Create a thumbnail. librr.create_thumbnails(output_filepath + '/' + image_filename, librr.thumbname_width) # Get relative file path. relative_image_filepath.append('./' + image_filename) if not is_loaded: continue accuracy_values = [] completeness_values = [] csv_filename_postfixes = [] csv_filename_postfixes.append('_baseline') for csv_filename_postfix in csv_filename_postfixes: csv_filename = dirname + '/' + prefix + csv_filename_postfix + '.csv' if symemtry_part_index >= 0: # Real per-part files. csv_filename = dirname + '/' + prefix + csv_filename_postfix\ + '_' + str(symemtry_part_index) + '.csv' all_values = librr.get_csv_value(csv_filename, librr.threshold) if not all_values: print('Warning: NaN values (' + prefix + ')') accuracy_values.append(float("NaN")) completeness_values.append(float("NaN")) else: accuracy_values.append(all_values[0]) completeness_values.append(all_values[1]) instance = OutputInstance(prefix, #relative_image_filepath[0], relative_image_filepath[1], relative_image_filepath[2], #relative_image_filepath[3], relative_image_filepath[4], accuracy_values[0], completeness_values[0]) instances.append(instance) return instances
def load_instances(input_filepath, output_filepath, symemtry_part_index): dirnames = glob.glob(input_filepath + '/*') instances = [] for dirname in dirnames: if not os.path.isdir(dirname): continue prefix = os.path.basename(dirname) print prefix is_loaded = True candidate_index = librr.find_best_candidate(dirname, prefix) print('Candidate index: ' + str(candidate_index)) # Read images. relative_image_filepath = [] image_filenames = [] image_filenames.append(prefix + '_view.png') image_filenames.append(prefix + '_input.png') image_filenames.append(prefix + '_' + str(candidate_index) + '.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_symmetry_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_symmetry_completeness.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_database_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_database_completeness.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_fusion_accuracy.png') image_filenames.append(prefix + '_' + str(candidate_index) + '_fusion_completeness.png') for image_filename in image_filenames: if not os.path.exists(dirname + '/' + image_filename): print 'Warning: File does not exist: "' + (dirname + '/' + image_filename) + '"' is_loaded = False break if not os.path.exists(output_filepath + '/' + image_filename): # Copy the image. shutil.copy(dirname + '/' + image_filename, output_filepath) # Create a thumbnail. librr.create_thumbnails(output_filepath + '/' + image_filename, librr.thumbname_width) # Get relative file path. relative_image_filepath.append('./' + image_filename) if not is_loaded: continue # Read stats. accuracy_values = [] completeness_values = [] csv_filename_postfixes = [] csv_filename_postfixes.append('_' + str(candidate_index) + '_symmetry') csv_filename_postfixes.append('_' + str(candidate_index) + '_database') csv_filename_postfixes.append('_' + str(candidate_index) + '_fusion') for csv_filename_postfix in csv_filename_postfixes: csv_filename = dirname + '/' + prefix + csv_filename_postfix + '.csv' if symemtry_part_index >= 0: # Read per-part files. csv_filename = dirname + '/' + prefix + csv_filename_postfix\ + '_' + str(symemtry_part_index) + '.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' is_loaded = False break else: all_values = librr.get_csv_value(csv_filename, librr.threshold) if not all_values: accuracy_values.append(float("NaN")) completeness_values.append(float("NaN")) else: accuracy_values.append(all_values[0]) completeness_values.append(all_values[1]) if not is_loaded: continue # Read per-point labeling accuracy. csv_filename = dirname + '/' + prefix + '_' + str(candidate_index) + '_labeling_stats.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' continue else: per_point_labeling_accuracy = read_value_from_csv_file(csv_filename, symemtry_part_index, 3) # Read cuboid distance to ground truth. csv_filename = dirname + '/' + prefix + '_' + str(candidate_index) + '_cuboid_distance.csv' if not os.path.exists(csv_filename): print 'Warning: File does not exist: "' + csv_filename + '"' continue else: cuboid_distance_to_ground_truth = read_value_from_csv_file(csv_filename, symemtry_part_index, 1) instance = OutputInstance(prefix, relative_image_filepath[0], relative_image_filepath[1], relative_image_filepath[2], relative_image_filepath[3], relative_image_filepath[4], relative_image_filepath[5], relative_image_filepath[6], relative_image_filepath[7], relative_image_filepath[8], accuracy_values[0], completeness_values[0], accuracy_values[1], completeness_values[1], accuracy_values[2], completeness_values[2], per_point_labeling_accuracy, cuboid_distance_to_ground_truth) instances.append(instance) return instances