Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a07e0d0

Browse files
[Feature]: move optimal conf_thresholds
1 parent 77c6714 commit a07e0d0

2 files changed

Lines changed: 79 additions & 73 deletions

File tree

configs/visualize_predictions.yaml

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,7 @@ defaults:
44

55
gt_path: data/final/metadata.xlsx
66
pred_path: data/interim_predict/SABL/metadata.xlsx
7-
conf_thresholds:
8-
Cephalization: 0.37
9-
Kerley: 0.53
10-
Effusion: 0.77
11-
Bat: 0.48
12-
Infiltrate: 0.38
137
# List of features: Cephalization, Artery, Heart, Kerley, Bronchus, Effusion, Bat, Infiltrate, Cuffing, Lungs
148
include_features: [Bat]
15-
save_images: false
9+
save_images: true
1610
save_dir: data/final_vis/SABL/bat
17-
18-
# Optimal thresholds:
19-
# ATSS:
20-
#conf_thresholds:
21-
# Cephalization: 0.27
22-
# Kerley: 0.54
23-
# Effusion: 0.36
24-
# Bat: 0.21
25-
# Infiltrate: 0.48
26-
27-
# Cascade RPN:
28-
#conf_thresholds:
29-
# Cephalization: 0.42
30-
# Kerley: 0.70
31-
# Effusion: 0.96
32-
# Bat: 0.50
33-
# Infiltrate: 0.75
34-
35-
# Faster R-CNN:
36-
#conf_thresholds:
37-
# Cephalization: 0.71
38-
# Kerley: 0.65
39-
# Effusion: 0.77
40-
# Bat: 0.62
41-
# Infiltrate: 0.99
42-
43-
# FSAF:
44-
#conf_thresholds:
45-
# Cephalization: 0.44
46-
# Kerley: 0.54
47-
# Effusion: 0.47
48-
# Bat: 0.45
49-
# Infiltrate: 0.39
50-
51-
# GFL:
52-
#conf_thresholds:
53-
# Cephalization: 0.32
54-
# Kerley: 0.60
55-
# Effusion: 0.51
56-
# Bat: 0.35
57-
# Infiltrate: 0.72
58-
59-
# PAA:
60-
#conf_thresholds:
61-
# Cephalization: 0.46
62-
# Kerley: 0.48
63-
# Effusion: 0.71
64-
# Bat: 0.56
65-
# Infiltrate: 0.71
66-
67-
# SABL:
68-
#conf_thresholds:
69-
# Cephalization: 0.37
70-
# Kerley: 0.53
71-
# Effusion: 0.77
72-
# Bat: 0.48
73-
# Infiltrate: 0.38
74-
75-
# TOOD:
76-
#conf_thresholds:
77-
# Cephalization: 0.25
78-
# Kerley: 0.41
79-
# Effusion: 0.36
80-
# Bat: 0.32
81-
# Infiltrate: 0.24

src/vis/visualize_predictions.py

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,79 @@
1212
log.setLevel(logging.INFO)
1313

1414

15+
def get_conf_thresholds(
16+
model_name: str,
17+
) -> dict:
18+
if model_name == 'ATSS':
19+
conf_thresholds = {
20+
'Cephalization': 0.27,
21+
'Kerley': 0.54,
22+
'Effusion': 0.36,
23+
'Bat': 0.21,
24+
'Infiltrate': 0.48,
25+
}
26+
elif model_name == 'Cascade RPN':
27+
conf_thresholds = {
28+
'Cephalization': 0.42,
29+
'Kerley': 0.70,
30+
'Effusion': 0.96,
31+
'Bat': 0.50,
32+
'Infiltrate': 0.75,
33+
}
34+
elif model_name == 'Faster R-CNN':
35+
conf_thresholds = {
36+
'Cephalization': 0.71,
37+
'Kerley': 0.65,
38+
'Effusion': 0.77,
39+
'Bat': 0.62,
40+
'Infiltrate': 0.99,
41+
}
42+
elif model_name == 'FSAF':
43+
conf_thresholds = {
44+
'Cephalization': 0.44,
45+
'Kerley': 0.54,
46+
'Effusion': 0.47,
47+
'Bat': 0.45,
48+
'Infiltrate': 0.39,
49+
}
50+
elif model_name == 'GFL':
51+
conf_thresholds = {
52+
'Cephalization': 0.32,
53+
'Kerley': 0.60,
54+
'Effusion': 0.51,
55+
'Bat': 0.35,
56+
'Infiltrate': 0.72,
57+
}
58+
elif model_name == 'PAA':
59+
conf_thresholds = {
60+
'Cephalization': 0.46,
61+
'Kerley': 0.48,
62+
'Effusion': 0.71,
63+
'Bat': 0.56,
64+
'Infiltrate': 0.71,
65+
}
66+
elif model_name == 'SABL':
67+
conf_thresholds = {
68+
'Cephalization': 0.37,
69+
'Kerley': 0.53,
70+
'Effusion': 0.77,
71+
'Bat': 0.48,
72+
'Infiltrate': 0.38,
73+
}
74+
elif model_name == 'TOOD':
75+
conf_thresholds = {
76+
'Cephalization': 0.25,
77+
'Kerley': 0.41,
78+
'Effusion': 0.36,
79+
'Bat': 0.32,
80+
'Infiltrate': 0.24,
81+
}
82+
else:
83+
raise ValueError(f'Unknown model: {model_name}')
84+
85+
return conf_thresholds
86+
87+
1588
def combine_data(
1689
gt_path: str,
1790
pred_path: str,
@@ -162,11 +235,15 @@ def visualize(
162235
def main(cfg: DictConfig) -> None:
163236
log.info(f'Config:\n\n{OmegaConf.to_yaml(cfg)}')
164237

238+
# Get optimal thresholds
239+
model_name = Path(cfg.pred_path).parent.name
240+
conf_thresholds = get_conf_thresholds(model_name)
241+
165242
# Combine ground truth and predictions
166243
dets = combine_data(
167244
gt_path=cfg.gt_path,
168245
pred_path=cfg.pred_path,
169-
conf_thresholds=cfg.conf_thresholds,
246+
conf_thresholds=conf_thresholds,
170247
include_features=cfg.include_features,
171248
)
172249

0 commit comments

Comments
 (0)