diff --git a/experiment/hdbscan/main_kitti_processing_hdbscan_voxel.py b/experiment/hdbscan/main_kitti_processing_hdbscan_voxel.py index e97dd09..149b0f8 100644 --- a/experiment/hdbscan/main_kitti_processing_hdbscan_voxel.py +++ b/experiment/hdbscan/main_kitti_processing_hdbscan_voxel.py @@ -21,22 +21,30 @@ def segment_pcds_by_hdbscan(start_index, end_index): - file_name = "experiment_bin_0704_4_sem_voxel_offset0_T0l03/start{}_end{}.pickle".format( - start_index, end_index + file_name = ( + "experiment_bin_0704_4_sem_voxel_offset0_T0l03/start{}_end{}.pickle".format( + start_index, end_index + ) ) - with open(file_name, 'rb') as file: + with open(file_name, "rb") as file: data = pickle.load(file) pcd_hdbscan_voxel_down_points = np.asarray(data[2]["voxel_pcd_original_points"]) pcd_hdbscan_voxel_down = o3d.geometry.PointCloud() - pcd_hdbscan_voxel_down.points = o3d.utility.Vector3dVector(pcd_hdbscan_voxel_down_points) + pcd_hdbscan_voxel_down.points = o3d.utility.Vector3dVector( + pcd_hdbscan_voxel_down_points + ) clusterer = HDBSCAN() clusters = clusterer.fit_predict(np.asarray(pcd_hdbscan_voxel_down.points)) return ( - {"hdbscan_clustered_voxel_pcd_original_points": np.asarray(pcd_hdbscan_voxel_down.points)}, + { + "hdbscan_clustered_voxel_pcd_original_points": np.asarray( + pcd_hdbscan_voxel_down.points + ) + }, {"hdbscan_voxel_trace_original": data[3]["voxel_trace_original"]}, {"hdbscan_clusters": clusters}, {"inst_label_array_for_clustering": data[6]["inst_label_array_for_clustering"]}, @@ -54,10 +62,8 @@ def process_kitti_hdbscan(from_num, to_num): result_tuple = segment_pcds_by_hdbscan(start_index, end_index) - file_name = ( - "experiment_bin_0704_4_sem_voxel_offset0_T0l03_hdbscan/start{}_end{}.pickle".format( - start_index, end_index - ) + file_name = "experiment_bin_0704_4_sem_voxel_offset0_T0l03_hdbscan/start{}_end{}.pickle".format( + start_index, end_index ) new_file = open(file_name, "w") new_file.close() diff --git a/experiment/hdbscan/main_kitti_processing_metrics_hdbscan.py b/experiment/hdbscan/main_kitti_processing_metrics_hdbscan.py index 203f22d..40cbfde 100644 --- a/experiment/hdbscan/main_kitti_processing_metrics_hdbscan.py +++ b/experiment/hdbscan/main_kitti_processing_metrics_hdbscan.py @@ -109,14 +109,14 @@ def main(): ): # в облаке нет инстансов => пропускаем skipped += 1 print( - "start_index={}, end_index={} skip".format( - start_index, end_index - ) + "start_index={}, end_index={} skip".format(start_index, end_index) ) current_from_num = end_index continue - clusters_list_without_noise = convert_clusters_to_list_of_point_arrays(clusters_array)[1:] + clusters_list_without_noise = convert_clusters_to_list_of_point_arrays( + clusters_array + )[1:] pred_inst_array = build_pred_inst_array( copy.deepcopy(inst_label_array_for_clustering), diff --git a/experiment/main_calc_metrics_by_csv.py b/experiment/main_calc_metrics_by_csv.py index a283a65..2c7d855 100644 --- a/experiment/main_calc_metrics_by_csv.py +++ b/experiment/main_calc_metrics_by_csv.py @@ -15,6 +15,17 @@ import csv +def calculate_sum_ones_zeros(values): + sum, ones, zeros = 0, 0, 0 + for value in values: + sum += float(value) + if float(value) == 1.0: + ones += 1 + elif float(value) == 0.0: + zeros += 1 + return sum, ones, zeros + + def calculate_metrics(file_name): values_pres = [] values_recall = [] @@ -26,35 +37,9 @@ def calculate_metrics(file_name): values_recall.append(row["recall"]) values_fScore.append(row["fScore"]) - sum_pres = 0 - pres1 = 0 - pres0 = 0 - for value in values_pres: - sum_pres += float(value) - if float(value) == 1.0: - pres1 += 1 - if float(value) == 0.0: - pres0 += 1 - - sum_recall = 0 - recall1 = 0 - recall0 = 0 - for value in values_recall: - sum_recall += float(value) - if float(value) == 1.0: - recall1 += 1 - if float(value) == 0.0: - recall0 += 1 - - sum_fScore = 0 - fscore1 = 0 - fscore0 = 0 - for value in values_fScore: - sum_fScore += float(value) - if float(value) == 1.0: - fscore1 += 1 - if float(value) == 0.0: - fscore0 += 1 + sum_pres, pres1, pres0 = calculate_sum_ones_zeros(values_pres) + sum_recall, recall1, recall0 = calculate_sum_ones_zeros(values_recall) + sum_fScore, fscore1, fscore0 = calculate_sum_ones_zeros(values_fScore) print( "precision={}, 1={}, 0={}".format(