Skip to content

Commit bfaddcb

Browse files
committed
Print processing time
1 parent f109887 commit bfaddcb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/baselines/eval_baseline.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def eval_all_ihc():
7777
"""
7878
cochlea_dir = "/mnt/vast-nhr/projects/nim00007/data/moser/cochlea-lightsheet"
7979
seg_dir = os.path.join(cochlea_dir, "predictions/val_ihc")
80-
annotation_dir = (cochlea_dir, "AnnotatedImageCrops/F1ValidationIHCs/consensus_annotation")
80+
annotation_dir = os.path.join(cochlea_dir, "AnnotatedImageCrops/F1ValidationIHCs/consensus_annotation")
8181
baselines = [
8282
"cellpose3",
8383
"cellpose-sam",
@@ -137,12 +137,14 @@ def print_accuracy(eval_dir):
137137
precision_list = []
138138
recall_list = []
139139
f1_score_list = []
140+
time_list = []
140141
for eval_dic in eval_dicts:
141142
with open(eval_dic, "r") as f:
142143
d = json.load(f)
143144
tp = len(d["tp_objects"])
144145
fp = len(d["fp"])
145146
fn = len(d["fn"])
147+
time = d["time"]
146148

147149
if tp + fp != 0:
148150
precision = tp / (tp + fp)
@@ -160,15 +162,17 @@ def print_accuracy(eval_dir):
160162
precision_list.append(precision)
161163
recall_list.append(recall)
162164
f1_score_list.append(f1_score)
165+
time_list.append(time)
163166

164-
names = ["Precision", "Recall", "F1 score"]
165-
for num, lis in enumerate([precision_list, recall_list, f1_score_list]):
167+
names = ["Precision", "Recall", "F1 score", "Time"]
168+
for num, lis in enumerate([precision_list, recall_list, f1_score_list, time_list]):
166169
print(names[num], sum(lis) / len(lis))
167170

168171

169172
def print_accuracy_sgn():
170173
"""Print 'Precision', 'Recall', and 'F1-score' for all SGN baselines.
171174
"""
175+
print("Evaluating SGN segmentation")
172176
cochlea_dir = "/mnt/vast-nhr/projects/nim00007/data/moser/cochlea-lightsheet"
173177
seg_dir = os.path.join(cochlea_dir, "predictions/val_sgn")
174178
baselines = [
@@ -185,6 +189,7 @@ def print_accuracy_sgn():
185189
def print_accuracy_ihc():
186190
"""Print 'Precision', 'Recall', and 'F1-score' for all IHC baselines.
187191
"""
192+
print("Evaluating IHC segmentation")
188193
cochlea_dir = "/mnt/vast-nhr/projects/nim00007/data/moser/cochlea-lightsheet"
189194
seg_dir = os.path.join(cochlea_dir, "predictions/val_ihc")
190195
baselines = [

0 commit comments

Comments
 (0)