Views
No views yet
KIRC/20250321_VAE_idim8516_md512_feat256mse_relu.pth - VAE weightsnetwork_reconstruction.pth - Reconstruction network weightsnetwork_dims.csv - Network architecture specificationsBRCA/20251209_VAE_idim8954_md1024_feat512mse_relu.pth - VAE weightsnetwork_reconstruction.pth - Reconstruction network weightsnetwork_dims.csv - Network architecture specifications1import torch
2import pandas as pd
3import json
4from pathlib import Path
5import huggingface_hub as hf
6from renalprog.modeling.train import VAE, NetworkReconstruction
7
8# Configuration
9cancer_type = "KIRC" # or "BRCA"
10device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
12# ============================================================================
13# Load VAE Model
14# ============================================================================
15
16# Download VAE config
17vae_config_path = hf.hf_hub_download(
18 repo_id="gprolcastelo/evenflow_models",
19 filename=f"{cancer_type}/config.json"
20)
21
22# Load configuration
23with open(vae_config_path, "r") as f:
24 vae_config = json.load(f)
25
26print(f"VAE Configuration: {vae_config}")
27
28# Download VAE model weights
29if cancer_type == "KIRC":
30 vae_filename = "KIRC/20250321_VAE_idim8516_md512_feat256mse_relu.pth"
31elif cancer_type == "BRCA":
32 vae_filename = "BRCA/20251209_VAE_idim8954_md1024_feat512mse_relu.pth"
33else:
34 raise ValueError(f"Unknown cancer type: {cancer_type}")
35
36vae_model_path = hf.hf_hub_download(
37 repo_id="gprolcastelo/evenflow_models",
38 filename=vae_filename
39)
40
41# Initialize and load VAE
42model_vae = VAE(
43 input_dim=vae_config["INPUT_DIM"],
44 mid_dim=vae_config["MID_DIM"],
45 features=vae_config["LATENT_DIM"]
46).to(device)
47
48checkpoint_vae = torch.load(vae_model_path, map_location=device, weights_only=False)
49model_vae.load_state_dict(checkpoint_vae)
50model_vae.eval()
51
52print(f"VAE model loaded successfully from {cancer_type}")
53
54# ============================================================================
55# Load Reconstruction Network
56# ============================================================================
57
58# Download network dimensions
59network_dims_path = hf.hf_hub_download(
60 repo_id="gprolcastelo/evenflow_models",
61 filename=f"{cancer_type}/network_dims.csv"
62)
63
64# Load network dimensions
65network_dims = pd.read_csv(network_dims_path)
66layer_dims = network_dims.values.tolist()[0]
67
68print(f"Reconstruction Network dimensions: {layer_dims}")
69
70# Download reconstruction network weights
71recnet_model_path = hf.hf_hub_download(
72 repo_id="gprolcastelo/evenflow_models",
73 filename=f"{cancer_type}/network_reconstruction.pth"
74)
75
76# Initialize and load Reconstruction Network
77model_recnet = NetworkReconstruction(layer_dims=layer_dims).to(device)
78checkpoint_recnet = torch.load(recnet_model_path, map_location=device, weights_only=False)
79model_recnet.load_state_dict(checkpoint_recnet)
80model_recnet.eval()
81
82print(f"Reconstruction Network loaded successfully from {cancer_type}")
83
84# ============================================================================
85# Use the models
86# ============================================================================
87
88# Example: Apply VAE to your data
89# your_data = torch.tensor(your_data_array).float().to(device)
90# with torch.no_grad():
91# vae_output = model_vae(your_data)
92# recnet_output = model_recnet(vae_output)
93⚠️ Warning
This citation is temporary. It will be updated when a pre-print is released.
1@software{renalprog2024,
2 title = {RenalProg: A Deep Learning Framework for Kidney Cancer Progression Modeling},
3 author = {[Guillermo Prol-Castelo, Elina Syrri, Nikolaos Manginas, Vasileos Manginas, Nikos Katzouris, Davide Cirillo, George Paliouras, Alfonso Valencia]},
4 year = {2025},
5 url = {https://github.com/gprolcas/renalprog},
6 note = {Preprint in preparation}
7}