Skip to content

Commit bac86b0

Browse files
committed
Final changes before submission :) :)
1 parent 2a88bc3 commit bac86b0

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

exec.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test(logger):
132132
test_predictor = Predictor(cf, net, logger, mode='test')
133133
test_evaluator = Evaluator(cf, logger, mode='test')
134134
batch_gen = data_loader.get_test_generator(cf, logger)
135-
# test_results_list = test_predictor.predict_test_set(batch_gen, return_results=True)
135+
test_results_list = test_predictor.predict_test_set(batch_gen, return_results=True)
136136

137137
# # print("Test without WBC")
138138
# wbc_bool = False
@@ -151,9 +151,9 @@ def test(logger):
151151
# load_pred_and_eval()
152152
# return
153153
fold = cf.fold
154-
bool_predict_test_set = False
155-
bool_predicted = False
156-
for wbc_bool in [False, True]:
154+
bool_predict_test_set = False #set to True to re run the predictions
155+
bool_predicted = False #bool used to avoid repeating predictions
156+
for wbc_bool in [True]: #[False, True]
157157
cf.fold = fold
158158
test_evaluator = Evaluator(cf, logger, mode='test')
159159
if bool_predict_test_set and not bool_predicted:
@@ -175,9 +175,9 @@ def test(logger):
175175

176176
for bool_low_lesion in [False, True]:
177177
print("wbc_bool : {} bool_low_lesion : {}".format(wbc_bool, bool_low_lesion))
178-
plot_test_prediction(copy.deepcopy(test_results_list), cf, wbc_bool, bool_low_lesion)#@rtgunti
178+
# plot_test_prediction(copy.deepcopy(test_results_list), cf, wbc_bool, bool_low_lesion)#@rtgunti
179179
break
180-
# break
180+
break
181181

182182

183183
# for test_result in test_results_list:

experiments/lidc_exp/configs.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
# limitations under the License.
1515
# ==============================================================================
1616

17-
from default_configs import DefaultConfigs
17+
1818
import numpy as np
1919
import sys
2020
import os
2121
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
22+
sys.path.append("/home/rgunti/medkit/")
23+
print(sys.path)
24+
from default_configs import DefaultConfigs
2225

2326

2427
class configs(DefaultConfigs):
@@ -31,7 +34,7 @@ def __init__(self, server_env=None):
3134

3235
self.data = ["Thesis", "LiTS"]
3336

34-
self.root_dir = '/home/ravi/Thesis'
37+
self.root_dir = '/home/rgunti/data/Thesis'
3538
self.raw_data_dir = '{}/data_raw/data/'.format(self.root_dir)
3639
self.raw_seg_dir = '{}/data_raw/seg/'.format(self.root_dir)
3740

@@ -55,7 +58,7 @@ def __init__(self, server_env=None):
5558
self.dim = 3
5659

5760
# one out of ['mrcnn', 'retina_net', 'retina_unet', 'detection_unet', 'ufrcnn', 'decoupled_refinement'].
58-
self.model = 'retina_net'
61+
self.model = 'decoupled_refinement'
5962

6063
DefaultConfigs.__init__(self, self.model, server_env, self.dim)
6164

@@ -67,10 +70,10 @@ def __init__(self, server_env=None):
6770
self.data_dest = ''
6871

6972
# path to preprocessed data.
70-
# self.pp_name = 'data_pp'
73+
self.pp_name = 'data_pp'
7174
# self.pp_name = 'data_pp_int'
7275
# self.pp_name = 'data_pp_wocrop'
73-
self.pp_name = 'data_pp_int_wocrop'
76+
# self.pp_name = 'data_pp_int_wocrop'
7477

7578
self.input_df_name = 'info_df.pickle'
7679
self.pp_data_path = '{}/{}/'.format(self.root_dir, self.pp_name)

plotting.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ def plot_test_prediction(results_list, cf, wbc_bool, bool_low_lesion, outfile=No
221221
except:
222222
raise Warning('failed to save plot.')
223223
plt.close(fig)
224-
# break
224+
print(outfile)
225+
break
225226

226227

227228
def plot_batch_prediction(batch, results_dict, cf, outfile= None):
@@ -523,10 +524,13 @@ def plot_stat_curves(stats, outfile):
523524
plt.figure()
524525
for s in stats:
525526
if s[c] is not None:
526-
s[c][1][0] = s[c][1][1]
527-
s[c][0][0] = 0
527+
# plt.plot(s[c][0], s[c][1], label=s['name'] + '_' + c) #line from original code. Plots look flipped somehow.
528+
# plt.plot(s[c][1], s[c][0], label=s['name'] + '_' + c) # If axes are interchanged, plot looks ok. But recall is forced to reach to 1 (since false negatives are marked at score 0). Plots look weird
529+
# To remove the last point from recall,
530+
s[c][1][0] = s[c][1][1] # Assign x coordinate of second value of recall to first value
531+
s[c][0][0] = 0 # Assign y coordinate of first point to 0 so that the curve drops to x axis after max recall is reached
528532
plt.plot(s[c][1], s[c][0], label=s['name'] + '_' + c )
529-
plt.plot([0,1], [1,0])
533+
plt.plot([0,1], [1,0]) #Add a diagonal line for reference
530534
break
531535
title += '\n Average Precision : ' + str(np.round(s['ap'], 3))
532536
plt.title(title)

predictor.py

+3
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ def load_saved_predictions(self, apply_wbc=True):
273273
pool.close()
274274
pool.join()
275275
else:
276+
'''
277+
If not using WBC, apply NMS for comparison
278+
'''
276279
apply_nms = True
277280
if apply_nms:
278281
self.logger.info('applying NMS to test set predictions with iou = {} and n_ens = {}.'.format(

utils/plot_comparison.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
exp_dir1 = exp_dir_62
3030
exp_dir2 = exp_dir_633_int_dcr
3131

32-
bool_plot_all_folds = False
33-
bool_plot_prc = False
32+
bool_plot_all_folds = True
33+
bool_plot_prc = True
3434
bool_plot_overall_with_wbc = True
3535

3636
exp_pairs = [

0 commit comments

Comments
 (0)