carbonscott / maxie

Masked Autoencoder for X-ray Image Encoding (MAXIE)
Other
2 stars 4 forks source link

Implement normalization #5

Closed carbonscott closed 4 months ago

carbonscott commented 4 months ago

This is the discussion about implementing normalization in maxie, a next step following #2 .

Implementing norm

Normalization itself should be available in torchvision (https://pytorch.org/vision/main/generated/torchvision.transforms.Normalize.html). It might be a good idea to create a wrapper so that our norm is conditioned on the detector in use. We can pass in the following dictionary to our custom norm class during initialization.

detector_norm_params = {
    'Rayonix': {'mean': 116.92, 'std': 22.89},
    'epix10k2M': {'mean': 46.6, 'std': 98.3},
    'jungfrau4M': {'mean': 593.17, 'std': 204.13}
}

The current dataset class is aware of which detector (detector_name) is associated with the current image. https://github.com/carbonscott/maxie/blob/f211b00dca0d51bd5514d0bc24e9179a6300a9d5/maxie/datasets/ipc_segmented_dataset_dist.py#L140

so the __call__(self, batch_img, **kwargs) in the normalization class can take an additional argument {'detector_name' : detector_name}.

Of course, we also need to add kwargs = ... in image_tensor = trans(image_tensor) https://github.com/carbonscott/maxie/blob/f211b00dca0d51bd5514d0bc24e9179a6300a9d5/maxie/datasets/ipc_segmented_dataset_dist.py#L152

Concerning the config