Skip to content
Snippets Groups Projects
Commit 77da14fc authored by Nuno Pimpão Santos Martins's avatar Nuno Pimpão Santos Martins
Browse files

update to script with fix to progress

parent f62c6c18
No related branches found
No related tags found
No related merge requests found
......@@ -12,8 +12,8 @@ from tqdm import tqdm
# Data Import
# ---
#raw data path
raw_mask_path = 'w:\\NPC_adult_new\\dl_training\\images\\'
raw_prefix_substring = '.tif'
raw_mask_path = 'w:\\NPC_adult_new\\dl_training\\images\\mask_gt\\'
raw_prefix_substring = '_mask'
# results paths
results_path = 'w:\\NPC_adult_new\\dl_training\\fcenet\\results\\'
......@@ -27,7 +27,7 @@ pred2_prefix_substring = '_x2'
pred3_mask_path = results_path+'results_x3\\'
pred3_prefix_substring = '_x3'
quantification_name = 'dlbiasfree'
quantification_name = 'fcenet'
raw_list = os.listdir(raw_mask_path)
raw_list.sort()
......@@ -52,12 +52,12 @@ if not os.path.exists(save_path):
time_start_script = time.time()
for raw_name, pred_name, pred_name2, pred_name3 in tqdm(zip(raw_list, pred_list, pred_list_x2, pred_list_x3)):
for raw_name, pred_name, pred_name2, pred_name3 in tqdm(zip(raw_list, pred_list, pred_list_x2, pred_list_x3), total=len(raw_list)):
time_image = time.time()
# to check if loaded images are the same
assert raw_name[:raw_name.index(raw_prefix_substring)] == pred_name[:pred_name.index(pred1_prefix_substring)], 'File names do not match :'+raw_name+', '+pred_name
assert pred_name[:pred_name.index(pred1_prefix_substring)] == pred_name2[:pred_name2.index(pred2_prefix_substring)], 'File names do not match.'
assert pred_name2[:pred_name2.index(pred2_prefix_substring)] == pred_name3[:pred_name3.index(pred3_prefix_substring)], 'File names do not match'
assert raw_name[:raw_name.index(raw_prefix_substring)] == pred_name[:pred_name.index(pred1_prefix_substring)], print('File names do not match :'+raw_name+', '+pred_name)
assert pred_name[:pred_name.index(pred1_prefix_substring)] == pred_name2[:pred_name2.index(pred2_prefix_substring)], print('File names do not match.')
assert pred_name2[:pred_name2.index(pred2_prefix_substring)] == pred_name3[:pred_name3.index(pred3_prefix_substring)], print('File names do not match')
print('Loading raw image name: ', raw_name)
image_raw = tifffile.imread(os.path.join(raw_mask_path, raw_name)).astype('float32')
......@@ -113,9 +113,10 @@ for raw_name, pred_name, pred_name2, pred_name3 in tqdm(zip(raw_list, pred_list,
else:
print('Mean IoU of {} and {}: {}'.format(pred_name2, pred_name3, np.mean(iou_data3[0, :])))
data_metrics = np.hstack((iou_data, iou_data2, iou_data3)).tolist()
print(data_metrics.shape)
stop
data_metrics = np.vstack((iou_data, iou_data2, iou_data3)).T.tolist()
# print(data_metrics.shape)
# stop
# data_metrics = data_metrics.tolist()
# ---
# Saving data
......@@ -125,7 +126,7 @@ for raw_name, pred_name, pred_name2, pred_name3 in tqdm(zip(raw_list, pred_list,
table_metrics = 'mse_metrics_%s.csv' % image_name_noext
with open(os.path.join(save_path, table_metrics), 'a') as outfile_metrics:
outfile_metrics.write('z_index,Raw vs x1,x1 vs x2,x2 vs x3,\n')
outfile_metrics.write('z_index,iou x1,threshold x1,iou x2,threshold x2,iou x3,threshold x3,\n')
for i in range(len(data_metrics)):
line = str(i+1)+','
for j in range(len(data_metrics[i])):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment