Views
No views yet
best_autoencoder.pt)best_refiner.pt)best_vae.pt)best_classifier.pt)1import torch
2from src.autoencoder import TriViewAutoencoder
3from src.reconstruction_utils import infer_in_channels_from_state_dict, infer_skip_channels_from_state_dict
4
5state_dict = torch.load("best_autoencoder.pt", map_location="cpu")
6if "model_state_dict" in state_dict:
7 state_dict = state_dict["model_state_dict"]
8
9in_channels = infer_in_channels_from_state_dict(state_dict)
10skip_channels = infer_skip_channels_from_state_dict(state_dict)
11latent_dim = int(state_dict["encoder.fc.1.weight"].shape[0])
12
13model = TriViewAutoencoder(latent_dim=latent_dim, in_channels=in_channels, skip_channels=skip_channels)
14model.load_state_dict(state_dict)
15model.eval()
16
17# Inference with TTA
18import torch.nn.functional as F
19x = ... # [batch, 3, 64, 64] projections
20pred = model(x)
21pred_flipped = model(x.flip(-1)).flip(-1)
22pred_avg = (pred + pred_flipped) / 2.0
23volume = torch.sigmoid(pred_avg) # [batch, 1, 64, 64, 64]train_colab.ipynb → best_autoencoder.pttrain_refiner_colab.ipynb → best_refiner.pt (needs stage 1)train_vae_colab.ipynb → best_vae.pt (independent)train_classifier_colab.ipynb → best_classifier.pt (needs stage 1)