Upload model
Browse files- config.json +1 -1
- configuration_uniformer.py +1 -1
- modelling_cxrmate_ed.py +8 -2
- prepare_dataset.py +18 -18
config.json
CHANGED
@@ -151,7 +151,7 @@
|
|
151 |
"max_length": 20,
|
152 |
"min_length": 0,
|
153 |
"mlp_ratio": 4,
|
154 |
-
"model_type": "
|
155 |
"no_repeat_ngram_size": 0,
|
156 |
"num_beam_groups": 1,
|
157 |
"num_beams": 1,
|
|
|
151 |
"max_length": 20,
|
152 |
"min_length": 0,
|
153 |
"mlp_ratio": 4,
|
154 |
+
"model_type": "vit",
|
155 |
"no_repeat_ngram_size": 0,
|
156 |
"num_beam_groups": 1,
|
157 |
"num_beams": 1,
|
configuration_uniformer.py
CHANGED
@@ -6,7 +6,7 @@ logger = logging.get_logger(__name__)
|
|
6 |
|
7 |
class UniFormerWithProjectionHeadConfig(PretrainedConfig):
|
8 |
|
9 |
-
model_type = '
|
10 |
|
11 |
def __init__(
|
12 |
self,
|
|
|
6 |
|
7 |
class UniFormerWithProjectionHeadConfig(PretrainedConfig):
|
8 |
|
9 |
+
model_type = 'vit'
|
10 |
|
11 |
def __init__(
|
12 |
self,
|
modelling_cxrmate_ed.py
CHANGED
@@ -948,7 +948,10 @@ class MIMICIVEDCXRMultimodalModel(VisionEncoderDecoderModel):
|
|
948 |
|
949 |
return position_ids
|
950 |
|
951 |
-
def get_dataset(self, dataset_path, train_transforms, test_transforms, max_train_images_per_study, study_id_split='mimic_iv_ed_mimic_cxr_jpg', test_set_only=False):
|
|
|
|
|
|
|
952 |
|
953 |
def train_set_transform(batch):
|
954 |
|
@@ -1051,7 +1054,10 @@ class MIMICIVEDCXRMultimodalModel(VisionEncoderDecoderModel):
|
|
1051 |
test_set.set_transform(test_set_transform)
|
1052 |
test_set = Subset(test_set, indices)
|
1053 |
|
1054 |
-
|
|
|
|
|
|
|
1055 |
|
1056 |
def get_stage_1_dataset(self, dataset_path, train_transforms, test_transforms, max_train_images_per_study):
|
1057 |
|
|
|
948 |
|
949 |
return position_ids
|
950 |
|
951 |
+
def get_dataset(self, dataset_path, train_transforms=None, test_transforms=None, max_train_images_per_study=None, study_id_split='mimic_iv_ed_mimic_cxr_jpg', test_set_only=False):
|
952 |
+
|
953 |
+
assert max_train_images_per_study is not None, 'max_train_images_per_study must be defined.'
|
954 |
+
assert test_transforms is not None, 'test_transforms must be defined.'
|
955 |
|
956 |
def train_set_transform(batch):
|
957 |
|
|
|
1054 |
test_set.set_transform(test_set_transform)
|
1055 |
test_set = Subset(test_set, indices)
|
1056 |
|
1057 |
+
if not test_set_only:
|
1058 |
+
return train_set, val_set, test_set
|
1059 |
+
else:
|
1060 |
+
return test_set
|
1061 |
|
1062 |
def get_stage_1_dataset(self, dataset_path, train_transforms, test_transforms, max_train_images_per_study):
|
1063 |
|
prepare_dataset.py
CHANGED
@@ -529,26 +529,26 @@ def prepare_dataset(physionet_dir, database_dir, num_workers=None):
|
|
529 |
lines=False,
|
530 |
)
|
531 |
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
|
548 |
-
|
549 |
-
|
550 |
|
551 |
-
|
552 |
|
553 |
|
554 |
if __name__ == "__main__":
|
|
|
529 |
lines=False,
|
530 |
)
|
531 |
|
532 |
+
dataset_dict[split] = datasets.Dataset.from_pandas(df)
|
533 |
+
cache_dir = os.path.join(database_dir, '.cache')
|
534 |
+
Path(cache_dir).mkdir(parents=True, exist_ok=True)
|
535 |
+
dataset_dict[split] = dataset_dict[split].map(
|
536 |
+
load_image,
|
537 |
+
num_proc=num_workers,
|
538 |
+
writer_batch_size=8,
|
539 |
+
batched=True,
|
540 |
+
batch_size=8,
|
541 |
+
keep_in_memory=False,
|
542 |
+
cache_file_name=os.path.join(cache_dir, f'.{split}'),
|
543 |
+
load_from_cache_file=False,
|
544 |
+
)
|
545 |
+
dataset_dict[split].cleanup_cache_files()
|
546 |
+
shutil.rmtree(cache_dir)
|
547 |
|
548 |
+
dataset = datasets.DatasetDict(dataset_dict)
|
549 |
+
dataset.save_to_disk(os.path.join(database_dir, 'mimic_iv_ed_mimic_cxr_jpg_dataset'))
|
550 |
|
551 |
+
con.close()
|
552 |
|
553 |
|
554 |
if __name__ == "__main__":
|