Skip to content

Commit

Permalink
latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
melanibe committed Feb 22, 2024
1 parent 71ebfec commit 40d826e
Show file tree
Hide file tree
Showing 12 changed files with 480 additions and 361 deletions.
2 changes: 2 additions & 0 deletions classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def train_model_main(config):
model_module = model_module.eval()
for p in model_module.parameters():
p.requires_grad = False
else:
model_module = model_module.train()

model_module.model.reset_classifier(data_module.num_classes)

Expand Down
4 changes: 2 additions & 2 deletions data_handling/mammo.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ def __getitem__(self, index) -> Any:
img = self.cache.get_slot(index)
# x will be None if the cache slot was empty or OOB
if img is None:
img, _ = preprocess_breast(self.imgs_paths[index], self.target_size)
img = preprocess_breast(self.imgs_paths[index], self.target_size)
self.cache.set_slot(index, img, allow_overwrite=True) # try to cache x
else:
img, _ = preprocess_breast(self.imgs_paths[index], self.target_size)
img = preprocess_breast(self.imgs_paths[index], self.target_size)

sample = {}
sample["view"] = self.views[index]
Expand Down
2 changes: 1 addition & 1 deletion environment_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- pytorch-cuda=12.1
- pip
- pip:
- lightning
- lightning>=2.2.0
- pandas
- numpy
- scikit-learn
Expand Down
81 changes: 38 additions & 43 deletions evaluation/chexpert_pneumo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,63 +46,65 @@
" \"simclr-0.1-33\": \"wtces7tl\",\n",
" \"simclr-0.1-22\": \"c0qmmgx1\",\n",
" \"simclr-0.1-11\": \"ouucdcl5\",\n",
" \"simclr-0.25-11\": \"np395uhs\",\n",
" \"simclr-0.25-22\": \"ypyw4lrc\",\n",
" \"simclr-0.25-33\": \"nrep0c0s\",\n",
"\n",
" \"supervised-0.1-11\": \"1kd02vig\",\n",
" \"supervised-1.0-22\": \"u6mm38zx\",\n",
" \"supervised-1.0-33\": \"wgq57ak4\",\n",
" \"supervised-1.0-11\": \"1e18dovk\",\n",
" \"supervised-0.1-33\": \"1njtbkre\",\n",
" \"supervised-0.1-22\": \"yl2qnv2s\",\n",
" \"supervised-0.25-11\": 'af029hmt',\n",
" 'supervised-0.25-22': 'r5rzknzo',\n",
" 'supervised-0.25-33': 'yms2a9pj',\n",
"\n",
" \"simclrcfaug-1.0-33\": \"toecr61u\",\n",
" \"simclrcfaug-0.1-33\": \"vvkk0rqq\",\n",
" \"simclrcfaug-1.0-22\": \"msyiln0g\",\n",
" \"simclrcfaug-0.1-22\": \"tmjl2u4z\",\n",
" \"simclrcfaug-1.0-11\": \"enhr8r5w\",\n",
" \"simclrcfaug-0.1-11\": \"528qi412\",\n",
" \"simclrcfaug-0.25-11\": \"vos0kkys\",\n",
" \"simclrcfaug-0.25-22\": \"p0ic7hbb\",\n",
" \"simclrcfaug-0.25-33\": \"dxyr38as\",\n",
"\n",
" \"simclrcf-0.1-11\": \"gxzgrx09\",\n",
" \"simclrcf-1.0-11\": \"mydv7jl9\",\n",
" \"simclrcf-0.1-22\": \"7fmc7i5u\",\n",
" \"simclrcf-1.0-22\": \"4nep2y5i\",\n",
" \"simclrcf-0.1-33\": \"rth6ff0x\",\n",
" \"simclrcf-1.0-33\": \"0ra6hohi\",\n",
" \"simclrcfhead-1.0-33\": \"6wcu7gvc\",\n",
" \"simclrcfhead-0.1-33\": \"n4ikil6m\",\n",
" \"simclrcfhead-1.0-22\": \"tz12fzrn\",\n",
" \"simclrcfhead-0.1-22\": \"k4fudcms\",\n",
" \"simclrcfhead-1.0-11\": \"kyterglf\",\n",
" \"simclrcfhead-0.1-11\": \"90fjagss\",\n",
" \"simclrcf-0.25-11\": \"gf75s11v\",\n",
" \"simclrcf-0.25-33\": \"tgot0avm\",\n",
" \"simclrcf-0.25-22\": \"dqozk1f5\",\n",
" \"simclr-0.25-11\": \"np395uhs\",\n",
" \"simclr-0.25-22\": \"ypyw4lrc\",\n",
" \"simclr-0.25-33\": \"nrep0c0s\",\n",
" \"simclrcfaug-0.25-11\": \"vos0kkys\",\n",
" \"simclrcfaug-0.25-22\": \"p0ic7hbb\",\n",
" \"simclrcfaug-0.25-33\": \"dxyr38as\",\n",
" \"simclrhead-0.1-11\": \"biw4ib4m\",\n",
" \"simclrcfaughead-0.1-11\": \"jmjtymks\",\n",
" \"simclrcfaughead-0.25-11\": \"073e0rqx\",\n",
" \"simclrhead-0.25-11\": \"by295tg3\",\n",
" \"simclrhead-1.0-11\": \"cflcfxy1\",\n",
" \"simclrcfaughead-1.0-11\": \"wut4tpcw\",\n",
" \"simclrcfaughead-0.1-22\": \"12iox806\",\n",
" \"simclrhead-0.1-22\": \"keggplfj\",\n",
" \"simclrcfaughead-0.25-22\": \"xa155jxa\",\n",
" \"simclrhead-0.25-22\": \"fhp2se09\",\n",
" \"simclrcfaughead-1.0-22\": \"y6tllsl9\",\n",
" \"simclrcfaughead-0.1-33\": \"lb8zjz2p\",\n",
" \"simclrhead-1.0-22\": \"k1sk453b\",\n",
" \"simclrcfaughead-0.25-33\": \"l5pvuj9s\",\n",
" \"simclrhead-0.25-33\": \"x5k0qjwn\",\n",
" \"simclrcfaughead-1.0-33\": \"suvlafdq\",\n",
" \"simclrcfhead-0.25-22\": \"j3xh5zum\",\n",
" \"simclrcfhead-0.25-33\": \"jfuql9yq\",\n",
" \"simclrcfhead-0.25-11\": \"h92wu2up\",\n",
" \"simclrhead-0.1-33\": \"x7afc3ic\",\n",
" \"simclrhead-1.0-33\": \"gj75gyod\",\n",
" \"supervised-0.25-11\": 'af029hmt',\n",
" 'supervised-0.25-22': 'r5rzknzo',\n",
" 'supervised-0.25-33': 'yms2a9pj'\n",
"\n",
" 'simclrhead-0.25-33': '85yznxgy',\n",
" 'simclrcfaughead-0.25-33': 'o29t3fk8',\n",
" 'simclrhead-1.0-33': '95qyx64t',\n",
" 'simclrhead-0.1-33': 'nlvsmcne',\n",
" 'simclrcfaughead-0.1-33': 'z96xslzy',\n",
" 'simclrcfaughead-1.0-33': '52e65qwx',\n",
" 'simclrcfaughead-0.25-22': 'm5sn2pr8',\n",
" 'simclrhead-0.25-22': 'uxu4dwzu',\n",
" 'simclrcfaughead-0.1-22': 'xhqtu3m2',\n",
" 'simclrcfaughead-1.0-22': 'of3d28jb',\n",
" 'simclrcfaughead-0.1-11': 'w6tbzaly',\n",
" 'simclrcfaughead-1.0-11': '4jvrmbpw',\n",
" 'simclrhead-1.0-22': '9m18itid',\n",
" 'simclrhead-0.25-11': '6iwtu99y',\n",
" 'simclrhead-0.1-11': 'hdimroq2',\n",
" 'simclrhead-1.0-11': '8o5owv7w',\n",
" 'simclrcfhead-0.25-33': 'hvq81iwv',\n",
" 'simclrcfhead-0.1-33': '2uigw3n5',\n",
" 'simclrcfhead-1.0-33': 'qx3bvg8m',\n",
" 'simclrcfhead-0.25-22': '4rquh0fm',\n",
" 'simclrcfhead-0.1-22': 'bhayhjze',\n",
" 'simclrcfhead-1.0-22': 'f5xtz51t',\n",
" 'simclrcfhead-0.25-11': '8nofqdss',\n",
" 'simclrcfhead-0.1-11': 'tck22uuf',\n",
" 'simclrcfhead-1.0-11': 'p9hoda5n', \n",
"}"
]
},
Expand Down Expand Up @@ -160,13 +162,6 @@
" f\"../outputs/classification_chexfinetunepneumo_results.csv\", index=False\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
132 changes: 77 additions & 55 deletions evaluation/embed_density.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions evaluation/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def extract_run_type(run_name):


def extract_pretraining_type(run_name):
run_name = re.split(r"-", run_name, maxsplit=1)[0]
if "simclrcfaug" in run_name:
return "SimCLR with CF\nin training set"
if "simclrcf" in run_name:
Expand All @@ -41,6 +42,7 @@ def extract_pretraining_type(run_name):


def extract_finetuning_type(run_name):
run_name = re.split(r"-", run_name, maxsplit=1)[0]
if "head" in run_name:
return "Linear Probing"
if "supervisedcf" in run_name or "cffine" in run_name:
Expand Down
85 changes: 42 additions & 43 deletions evaluation/padchest_pneumo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@
" \"supervised-1.0-22\": \"4oaaikt6\",\n",
" \"supervised-1.0-33\": \"n8h9oapi\",\n",
" \"supervised-1.0-11\": \"ghopk3ju\",\n",
" \"supervised-0.05-11\": 'yhhb9ytj',\n",
" \"supervised-0.05-22\": \"bx6gi5ib\",\n",
" \"supervised-0.05-33\": 'wbhd0e7x',\n",
" \"supervised-0.25-11\": 'jtwn5ni9',\n",
" \"supervised-0.25-22\": 'yll5f08y',\n",
" \"supervised-0.25-33\": 'mcyuc9hr',\n",
"\n",
" \"simclr-0.1-22\": \"n4q4a33f\",\n",
" \"simclr-0.1-33\": \"3z4co0f5\",\n",
" \"simclr-0.1-11\": \"u2hzkzi8\",\n",
" \"simclr-1.0-22\": \"4pe40g5x\",\n",
" \"simclr-1.0-33\": \"fph8u80n\",\n",
" \"simclr-1.0-11\": \"hqvqp4mh\",\n",
" \"simclrhead-1.0-33\": \"bctalde0\",\n",
" \"simclrhead-0.1-33\": \"ubv6eqfz\",\n",
" \"simclrhead-0.1-22\": \"wi03qw05\",\n",
" \"simclrhead-1.0-22\": \"g92xolyv\",\n",
" \"simclrhead-0.1-11\": \"lfhrzwlc\",\n",
" \"simclrhead-1.0-11\": \"tc5riibq\",\n",
" \"simclrcfaug-0.1-33\": \"zqv28q1c\",\n",
" \"simclrcfaug-1.0-33\": \"hu8wg6s4\",\n",
" \"simclrcfaug-0.1-22\": \"8xf5b6ts\",\n",
Expand All @@ -73,18 +74,6 @@
" \"simclrcf-1.0-33\": \"gcn4pmb5\",\n",
" \"simclrcf-1.0-11\": \"bjurudm1\",\n",
" \"simclrcf-0.1-33\": \"givxkg9r\",\n",
" \"simclrcfhead-0.1-22\": \"2cfdu2ru\",\n",
" \"simclrcfhead-1.0-11\": \"aev41p0o\",\n",
" \"simclrcfhead-0.1-11\": \"ql05brkt\",\n",
" \"simclrcfhead-0.25-11\": \"p57dgkwp\",\n",
" \"simclrcfhead-0.05-11\": \"go6laxdr\",\n",
" \"simclrcfhead-0.05-22\": \"vp98mhg4\",\n",
" \"simclrcfhead-0.25-22\": \"6wjmiqcf\",\n",
" \"simclrcfhead-0.05-33\": \"zwpn5i97\",\n",
" \"simclrcfhead-0.1-33\": \"7ksiuau7\",\n",
" \"simclrcfhead-0.25-33\": \"xjhdufsk\",\n",
" \"simclrcfhead-1.0-33\": \"qoqqvcjk\",\n",
" \"simclrcfhead-1.0-22\": \"9o431mp5\",\n",
" \"simclrcf-0.05-11\": \"yuw1hej0\",\n",
" \"simclrcf-0.25-11\": \"zzr4utap\",\n",
" \"simclrcf-0.05-22\": \"46orb30r\",\n",
Expand All @@ -103,31 +92,41 @@
" \"simclrcfaug-0.25-22\": \"7r316b1j\",\n",
" \"simclrcfaug-0.05-33\": \"edk3wfn3\",\n",
" \"simclrcfaug-0.25-33\": \"yuwmsfoz\",\n",
" \"simclrcfaughead-0.05-22\": \"0sqtorl6\",\n",
" \"simclrcfaughead-0.05-11\": \"8m2e86xr\",\n",
" \"simclrcfaughead-0.05-33\": \"arzhs7kv\",\n",
" \"simclrcfaughead-0.25-33\": \"wpz8ltrm\",\n",
" \"simclrcfaughead-0.25-22\": \"pai5bnm4\",\n",
" \"simclrcfaughead-0.25-11\": \"x0pmqpy9\",\n",
" \"simclrhead-0.1-33\": \"pqr1shrw\",\n",
" \"simclrcfaughead-1.0-22\": \"t1zylip4\",\n",
" \"simclrcfaughead-1.0-33\": \"7p01aii1\",\n",
" \"simclrhead-0.05-11\": \"x1y3cyvr\",\n",
" \"simclrhead-0.05-22\": \"x9a09lea\",\n",
" \"simclrhead-0.05-33\": \"wrx49m90\",\n",
" \"simclrhead-0.25-11\": \"0j3vd0uj\",\n",
" \"simclrhead-0.25-22\": \"t48vsxm3\",\n",
" \"simclrhead-0.25-33\": \"814m80w1\",\n",
" \"simclrcfaughead-0.1-11\": \"7nu2zser\",\n",
" \"simclrcfaughead-0.1-22\": \"luxwk9xc\",\n",
" \"simclrcfaughead-0.1-33\": \"r5asb39l\",\n",
" \"simclrcfaughead-1.0-11\": \"s9ub63yt\",\n",
" \"supervised-0.05-11\": 'yhhb9ytj',\n",
" \"supervised-0.05-22\": \"bx6gi5ib\",\n",
" \"supervised-0.05-33\": 'wbhd0e7x',\n",
" \"supervised-0.25-11\": 'jtwn5ni9',\n",
" \"supervised-0.25-22\": 'yll5f08y',\n",
" \"supervised-0.25-33\": 'mcyuc9hr',\n",
" \n",
" 'simclrhead-0.25-33': 'sjeg48br',\n",
" 'simclrcfaughead-0.25-33': 'n3r9fiz3',\n",
" 'simclrcfaughead-0.1-33': 'zjcf6740',\n",
" 'simclrcfaughead-1.0-33': 'hhmtknho',\n",
" 'simclrhead-1.0-33': 'maq90iwt',\n",
" 'simclraughead-0.25-22': '6to2f7a0',\n",
" 'simclrcfaughead-0.1-22': '4nfbi6tl',\n",
" 'simclrcfaughead-1.0-22': 'skb167qn',\n",
" 'simclrhead-0.25-22': 'cc2cdd76',\n",
" 'simclrcfaughead-0.25-11': 'ozkj5npc',\n",
" 'simclrhead-0.1-22': '6hh5p3wu',\n",
" 'simclrcfaughead-0.1-11': 'g9i9fshy',\n",
" 'simclrhead-1.0-22': 'ujg8b6kr',\n",
" 'simclrcfaughead-1.0-11': 'fzb2gg18',\n",
" 'simclrhead-0.25-11': 'w5c1uilu',\n",
" 'simclrhead-0.1-11': 'kjy8kd4j',\n",
" 'simclrhead-1.0-11': 'h7b924ww',\n",
" 'simclrcfhead-0.25-33': '8fbh0up5',\n",
" 'simclrcfhead-0.1-33': 'sfqu07v6',\n",
" 'simclrcfhead-0.25-11': 'crn58bt4',\n",
" 'simclrcfhead-0.1-11': 'ipxh9y6b',\n",
" 'simclrcfhead-0.25-22': 'yj99p9gk',\n",
" 'simclrcfhead-1.0-11': '3cj3p5ha',\n",
" 'simclrcfaughead-0.05-11': 'w8o2l2bp',\n",
" 'simclrcfaughead-0.05-22': '98wsobp9',\n",
" 'simclrhead-0.05-33': 'qjb0j9cp',\n",
" 'simclrcfaughead-0.05-33': '93uflh60',\n",
" 'simclrcfhead-0.05-33': 'c2ssrqf7',\n",
" 'simclrhead-0.05-22': 'wzcayezk',\n",
" 'simclrcfhead-0.05-22': 'lvjitftj',\n",
" 'simclrhead-0.05-11': '0t8nbhc7',\n",
" 'simclrcfhead-0.05-11': 'e7kw2tuf',\n",
" 'simclrcfhead-1.0-33': '5et2yzej',\n",
" 'simclrcfhead-1.0-22':'t0zmf1lp'\n",
"}"
]
},
Expand Down
218 changes: 188 additions & 30 deletions evaluation/plot_all_results.ipynb

Large diffs are not rendered by default.

141 changes: 33 additions & 108 deletions evaluation/pngs_for_figures.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 40d826e

Please sign in to comment.