convitom commited on
Commit ·
0b18c4a
1
Parent(s): cba2b6c
data/mimic_cxr_resized_builder.py
CHANGED
|
@@ -193,6 +193,7 @@ def build_mimic_cxr_resized_instruct_json(
|
|
| 193 |
pnu_by_study: Dict[Tuple[str, str], str] = {} # (subj, study) → PNU string (for VQA reuse)
|
| 194 |
|
| 195 |
n_studies = n_missing_report = 0
|
|
|
|
| 196 |
skipped_merged_no_impression = skipped_cascade_no_findings = 0
|
| 197 |
|
| 198 |
for fname, split_label in _MANIFEST_FILES:
|
|
@@ -210,10 +211,22 @@ def build_mimic_cxr_resized_instruct_json(
|
|
| 210 |
|
| 211 |
# All views of the same study share report + CheXpert labels.
|
| 212 |
first = rows[0]
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
-
# Index every
|
| 216 |
-
# row that references this image can still be picked up below.
|
| 217 |
for r in rels:
|
| 218 |
image_index[r] = r
|
| 219 |
|
|
@@ -330,6 +343,8 @@ def build_mimic_cxr_resized_instruct_json(
|
|
| 330 |
print(f" image_mode : {image_mode}")
|
| 331 |
print(f" studies indexed : {n_studies:,}")
|
| 332 |
print(f" missing report : {n_missing_report:,}")
|
|
|
|
|
|
|
| 333 |
if report_mode == "merged":
|
| 334 |
print(f" skipped no_impr : {skipped_merged_no_impression:,}")
|
| 335 |
if report_mode == "split_cascade":
|
|
|
|
| 193 |
pnu_by_study: Dict[Tuple[str, str], str] = {} # (subj, study) → PNU string (for VQA reuse)
|
| 194 |
|
| 195 |
n_studies = n_missing_report = 0
|
| 196 |
+
n_missing_image = n_studies_no_image = 0
|
| 197 |
skipped_merged_no_impression = skipped_cascade_no_findings = 0
|
| 198 |
|
| 199 |
for fname, split_label in _MANIFEST_FILES:
|
|
|
|
| 211 |
|
| 212 |
# All views of the same study share report + CheXpert labels.
|
| 213 |
first = rows[0]
|
| 214 |
+
all_rels = [r["image_relpath"] for r in rows]
|
| 215 |
+
|
| 216 |
+
# Filter out rows whose image file is missing on disk (resize/shard
|
| 217 |
+
# can drop a few JPGs that failed to encode; manifest still lists
|
| 218 |
+
# them). Keep VQA index consistent with the SURVIVING images only.
|
| 219 |
+
rels = []
|
| 220 |
+
for r in all_rels:
|
| 221 |
+
if (root / r).is_file():
|
| 222 |
+
rels.append(r)
|
| 223 |
+
else:
|
| 224 |
+
n_missing_image += 1
|
| 225 |
+
if not rels:
|
| 226 |
+
n_studies_no_image += 1
|
| 227 |
+
continue
|
| 228 |
|
| 229 |
+
# Index every (surviving) image for the VQA lookup pass below.
|
|
|
|
| 230 |
for r in rels:
|
| 231 |
image_index[r] = r
|
| 232 |
|
|
|
|
| 343 |
print(f" image_mode : {image_mode}")
|
| 344 |
print(f" studies indexed : {n_studies:,}")
|
| 345 |
print(f" missing report : {n_missing_report:,}")
|
| 346 |
+
print(f" missing image rows: {n_missing_image:,}")
|
| 347 |
+
print(f" studies w/o image : {n_studies_no_image:,} (dropped entirely)")
|
| 348 |
if report_mode == "merged":
|
| 349 |
print(f" skipped no_impr : {skipped_merged_no_impression:,}")
|
| 350 |
if report_mode == "split_cascade":
|
scripts/cxrvlm_colab_train.ipynb
CHANGED
|
@@ -68,7 +68,7 @@
|
|
| 68 |
"REPORT_MODE = 'split_cascade' # 'split' | 'merged' | 'split_cascade'\n",
|
| 69 |
"IMAGE_MODE = 'all_views_split' # 'all_views_split' | 'frontal_only_split' | 'multi_image_merged'\n",
|
| 70 |
"S1_EPOCHS = 2\n",
|
| 71 |
-
"S2_EPOCHS =
|
| 72 |
"MODE = 'fresh' # 'fresh' | 'resume'\n",
|
| 73 |
"EXPLICIT_RUN_ID = None # None | 'IU-Xray_run_5' (only matters when MODE='resume')\n",
|
| 74 |
"\n",
|
|
@@ -992,7 +992,7 @@
|
|
| 992 |
"outputs": [],
|
| 993 |
"source": [
|
| 994 |
"# ── (Optional) Stage-1 ITC alignment toggle ─────────────────────────\n",
|
| 995 |
-
"USE_ITC =
|
| 996 |
"ITC_REPO_ID = 'hieu3636/cxr-vlm-data'\n",
|
| 997 |
"ITC_SUBDIR = 'cxr_bert_text_embeddings'\n",
|
| 998 |
"ITC_TEMPERATURE = 0.07\n",
|
|
@@ -1072,7 +1072,7 @@
|
|
| 1072 |
"# unique images that's ~90 GB — make sure WORK has the room, or set\n",
|
| 1073 |
"# CACHE_FEATURES=False on tight quotas.\n",
|
| 1074 |
"\n",
|
| 1075 |
-
"CACHE_FEATURES =
|
| 1076 |
"\n",
|
| 1077 |
"if CACHE_FEATURES:\n",
|
| 1078 |
" feature_cache_dir = WORK / 'feature_cache' / DATASET_NAME\n",
|
|
@@ -1723,4 +1723,4 @@
|
|
| 1723 |
},
|
| 1724 |
"nbformat": 4,
|
| 1725 |
"nbformat_minor": 5
|
| 1726 |
-
}
|
|
|
|
| 68 |
"REPORT_MODE = 'split_cascade' # 'split' | 'merged' | 'split_cascade'\n",
|
| 69 |
"IMAGE_MODE = 'all_views_split' # 'all_views_split' | 'frontal_only_split' | 'multi_image_merged'\n",
|
| 70 |
"S1_EPOCHS = 2\n",
|
| 71 |
+
"S2_EPOCHS = 7\n",
|
| 72 |
"MODE = 'fresh' # 'fresh' | 'resume'\n",
|
| 73 |
"EXPLICIT_RUN_ID = None # None | 'IU-Xray_run_5' (only matters when MODE='resume')\n",
|
| 74 |
"\n",
|
|
|
|
| 992 |
"outputs": [],
|
| 993 |
"source": [
|
| 994 |
"# ── (Optional) Stage-1 ITC alignment toggle ─────────────────────────\n",
|
| 995 |
+
"USE_ITC = True # True → contrastive Stage-1 (no Vicuna); False → original\n",
|
| 996 |
"ITC_REPO_ID = 'hieu3636/cxr-vlm-data'\n",
|
| 997 |
"ITC_SUBDIR = 'cxr_bert_text_embeddings'\n",
|
| 998 |
"ITC_TEMPERATURE = 0.07\n",
|
|
|
|
| 1072 |
"# unique images that's ~90 GB — make sure WORK has the room, or set\n",
|
| 1073 |
"# CACHE_FEATURES=False on tight quotas.\n",
|
| 1074 |
"\n",
|
| 1075 |
+
"CACHE_FEATURES = False\n",
|
| 1076 |
"\n",
|
| 1077 |
"if CACHE_FEATURES:\n",
|
| 1078 |
" feature_cache_dir = WORK / 'feature_cache' / DATASET_NAME\n",
|
|
|
|
| 1723 |
},
|
| 1724 |
"nbformat": 4,
|
| 1725 |
"nbformat_minor": 5
|
| 1726 |
+
}
|