| import os | |
| import sys | |
| import torch | |
| sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src")) | |
| from gliomasam3_moe.models.gliomasam3_moe import GliomaSAM3_MoE | |
| def test_model_shapes(): | |
| model = GliomaSAM3_MoE( | |
| patch_size=16, | |
| token_dim=64, | |
| depth=2, | |
| heads=4, | |
| slice_attn_k=4, | |
| spectral_bins=8, | |
| spectral_q=3, | |
| moe_experts=5, | |
| moe_topk=2, | |
| decoder_hidden=32, | |
| prompt_mlp_hidden=64, | |
| ) | |
| x = torch.randn(2, 4, 16, 128, 128) | |
| logits, aux = model(x) | |
| assert logits.shape == (2, 3, 16, 128, 128) | |
| assert "pi_et" in aux | |
| assert "moe_gamma" in aux | |
| assert "spectral_stats" in aux | |
| assert "et_prob_gated" in aux | |