diff --git a/config_files/config_preproc.yaml b/config_files/config_preproc.yaml index 4c503cc..0a087c9 100644 --- a/config_files/config_preproc.yaml +++ b/config_files/config_preproc.yaml @@ -1,5 +1,4 @@ submission_config_file: submission_config.json -seed_flavor_assignment: 0 thresh_percentile: 93.0 BOT_box_size: 32 BOT_loss: wemd diff --git a/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py b/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py index 589239c..90ccc51 100644 --- a/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py +++ b/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py @@ -1,5 +1,4 @@ import torch -import numpy as np import json import os @@ -40,34 +39,7 @@ def save_submission(volumes, populations, submission_id, submission_index, confi def preprocess_submissions(submission_dataset, config): - np.random.seed(config["seed_flavor_assignment"]) - ice_cream_flavors = [ - "Chocolate", - "Vanilla", - "Cookies N' Cream", - "Mint Chocolate Chip", - "Strawberry", - "Butter Pecan", - "Salted Caramel", - "Pistachio", - "Rocky Road", - "Coffee", - "Cookie Dough", - "Chocolate Chip", - "Neapolitan", - "Cherry", - "Rainbow Sherbet", - "Peanut Butter", - "Cotton Candy", - "Lemon Sorbet", - "Mango", - "Black Raspberry", - ] - - n_subs = max(submission_dataset.subs_index) + 1 - random_mapping = np.random.choice(len(ice_cream_flavors), n_subs, replace=False) hash_table = {} - box_size_gt = submission_dataset.submission_config["gt"]["box_size"] pixel_size_gt = submission_dataset.submission_config["gt"]["pixel_size"] vol_gt_ref = submission_dataset.vol_gt_ref @@ -75,9 +47,12 @@ def preprocess_submissions(submission_dataset, config): for i in range(len(submission_dataset)): idx = submission_dataset.subs_index[i] - hash_table[submission_dataset.submission_config[str(idx)]["name"]] = ( - ice_cream_flavors[random_mapping[idx]] - ) + sub_flavor = submission_dataset.submission_config[str(idx)]["flavor_name"] + sub_name = submission_dataset.submission_config[str(idx)]["name"] + hash_table[sub_flavor] = { + "name": sub_name, + "filename": f"submission_{idx}.pt", + } print(f"Preprocessing submission {idx}...") @@ -126,8 +101,11 @@ def preprocess_submissions(submission_dataset, config): submission_version = "" else: submission_version = f" {submission_version}" - print(f" SUBMISSIION VERSION {submission_version}") - submission_id = ice_cream_flavors[random_mapping[idx]] + submission_version + print(f" SUBMISSION VERSION {submission_version}") + submission_id = ( + submission_dataset.submission_config[str(idx)]["flavor_name"] + + submission_version + ) print(f"SUBMISSION ID {submission_id}") save_submission( diff --git a/src/cryo_challenge/data/_validation/config_validators.py b/src/cryo_challenge/data/_validation/config_validators.py index 93316a0..b2fa933 100644 --- a/src/cryo_challenge/data/_validation/config_validators.py +++ b/src/cryo_challenge/data/_validation/config_validators.py @@ -1,7 +1,7 @@ from numbers import Number import pandas as pd import os -from typing import List + def validate_generic_config(config: dict, reference: dict) -> None: """ @@ -48,7 +48,6 @@ def validate_config_preprocessing(config_data: dict) -> None: "BOT_loss": str, "BOT_iter": Number, "BOT_refine": bool, - "seed_flavor_assignment": int, } validate_generic_config(config_data, keys_and_types) return diff --git a/tests/config_files/test_config_preproc.yaml b/tests/config_files/test_config_preproc.yaml index 0a27d7e..0d0fec5 100644 --- a/tests/config_files/test_config_preproc.yaml +++ b/tests/config_files/test_config_preproc.yaml @@ -1,5 +1,4 @@ submission_config_file: tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json -seed_flavor_assignment: 0 thresh_percentile: 93.0 BOT_box_size: 32 BOT_loss: wemd diff --git a/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json b/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json index 5671514..b8318b9 100644 --- a/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json +++ b/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json @@ -9,6 +9,7 @@ "0": { "name": "raw_submission_in_testdata", "align": 1, + "flavor_name": "test flavor", "box_size": 244, "pixel_size": 2.146, "path": "tests/data/unprocessed_dataset_2_submissions/submission_x",