Views
No views yet
cd /path/to/OpenPhenom
pip install -e .PCA-CenterScale pattern or better yet Typical Variation Normalization:return_channelwise_embeddings=True)1import pytest
2import torch
3
4from huggingface_mae import MAEModel
5
6# huggingface_openphenom_model_dir = "."
7huggingface_modelpath = "recursionpharma/OpenPhenom"
8
9
10@pytest.fixture
11def huggingface_model():
12 # This step downloads the model to a local cache, takes a bit to run
13 huggingface_model = MAEModel.from_pretrained(huggingface_modelpath)
14 huggingface_model.eval()
15 return huggingface_model
16
17
18@pytest.mark.parametrize("C", [1, 4, 6, 11])
19@pytest.mark.parametrize("return_channelwise_embeddings", [True, False])
20def test_model_predict(huggingface_model, C, return_channelwise_embeddings):
21 example_input_array = torch.randint(
22 low=0,
23 high=255,
24 size=(2, C, 256, 256),
25 dtype=torch.uint8,
26 device=huggingface_model.device,
27 )
28 huggingface_model.return_channelwise_embeddings = return_channelwise_embeddings
29 embeddings = huggingface_model.predict(example_input_array)
30 expected_output_dim = 384 * C if return_channelwise_embeddings else 384
31 assert embeddings.shape == (2, expected_output_dim)1@inproceedings{kraus2024masked,
2 title={Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology},
3 author={Kraus, Oren and Kenyon-Dean, Kian and Saberian, Saber and Fallah, Maryam and McLean, Peter and Leung, Jess and Sharma, Vasudev and Khan, Ayla and Balakrishnan, Jia and Celik, Safiye and others},
4 booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
5 pages={11757--11768},
6 year={2024}
7}