Skip to content

Commit

Permalink
Merge branch 'dev' into add-vista2d
Browse files Browse the repository at this point in the history
  • Loading branch information
yiheng-wang-nv authored Aug 21, 2024
2 parents 8c107d6 + 8144321 commit f8e7e9c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
64
],
"autoencoder_def": {
"_target_": "generative.networks.nets.AutoencoderKL",
"_target_": "monai.networks.nets.autoencoderkl.AutoencoderKL",
"spatial_dims": "@spatial_dims",
"in_channels": "@image_channels",
"out_channels": "@image_channels",
"latent_channels": "@latent_channels",
"num_channels": [
"channels": [
64,
128,
256
Expand All @@ -43,14 +43,15 @@
false
],
"with_encoder_nonlocal_attn": true,
"with_decoder_nonlocal_attn": true
"with_decoder_nonlocal_attn": true,
"include_fc": false
},
"network_def": {
"_target_": "generative.networks.nets.DiffusionModelUNet",
"_target_": "monai.networks.nets.diffusion_model_unet.DiffusionModelUNet",
"spatial_dims": "@spatial_dims",
"in_channels": "@latent_channels",
"out_channels": "@latent_channels",
"num_channels": [
"channels": [
32,
64,
128,
Expand All @@ -68,16 +69,18 @@
32,
32
],
"num_res_blocks": 2
"num_res_blocks": 2,
"include_fc": false,
"use_combined_linear": false
},
"load_autoencoder_path": "$@bundle_root + '/models/model_autoencoder.pt'",
"load_autoencoder": "$@autoencoder_def.load_state_dict(torch.load(@load_autoencoder_path))",
"load_autoencoder": "$@autoencoder_def.load_old_state_dict(torch.load(@load_autoencoder_path))",
"autoencoder": "$@autoencoder_def.to(@device)",
"load_diffusion_path": "$@model_dir + '/model.pt'",
"load_diffusion": "$@network_def.load_state_dict(torch.load(@load_diffusion_path))",
"load_diffusion": "$@network_def.load_old_state_dict(torch.load(@load_diffusion_path))",
"diffusion": "$@network_def.to(@device)",
"noise_scheduler": {
"_target_": "generative.networks.schedulers.DDIMScheduler",
"_target_": "monai.networks.schedulers.ddim.DDIMScheduler",
"_requires_": [
"@load_diffusion",
"@load_autoencoder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"infer_batch_size_img": 1,
"infer_batch_size_slice": 1,
"autoencoder_def": {
"_target_": "generative.networks.nets.AutoencoderKL",
"_target_": "monai.networks.nets.autoencoderkl.AutoencoderKL",
"spatial_dims": "@spatial_dims",
"in_channels": "@image_channels",
"out_channels": "@image_channels",
"latent_channels": "@latent_channels",
"num_channels": [
"channels": [
64,
128,
256
Expand All @@ -43,10 +43,11 @@
false
],
"with_encoder_nonlocal_attn": true,
"with_decoder_nonlocal_attn": true
"with_decoder_nonlocal_attn": true,
"include_fc": false
},
"load_autoencoder_path": "$@bundle_root + '/models/model_autoencoder.pt'",
"load_autoencoder": "$@autoencoder_def.load_state_dict(torch.load(@load_autoencoder_path))",
"load_autoencoder": "$@autoencoder_def.load_old_state_dict(torch.load(@load_autoencoder_path))",
"autoencoder": "$@autoencoder_def.to(@device)",
"preprocessing_transforms": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_generator_ldm_20230507.json",
"version": "1.0.9",
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json",
"version": "1.0.10",
"changelog": {
"1.0.10": "update to use monai 1.4, model ckpt not changed, rm GenerativeAI repo",
"1.0.9": "update to use monai 1.3.1",
"1.0.8": "define arg for output file and put infer logic into a function",
"1.0.7": "update AddChanneld with EnsureChannelFirstd",
Expand All @@ -13,14 +14,14 @@
"1.0.1": "fix inference folder error",
"1.0.0": "Initial release"
},
"monai_version": "1.3.1",
"monai_version": "1.4.0",
"pytorch_version": "2.2.2",
"numpy_version": "1.24.4",
"optional_packages_version": {
"required_packages_version": {
"nibabel": "5.2.1",
"lpips": "0.1.4",
"monai-generative": "0.2.2"
"lpips": "0.1.4"
},
"supported_apps": {},
"name": "BraTS MRI axial slices latent diffusion generation",
"task": "BraTS MRI axial slices synthesis",
"description": "A generative model for creating 2D brain MRI axial slices from Gaussian noise based on BraTS dataset",
Expand Down Expand Up @@ -71,7 +72,7 @@
}
}
},
"generator_data_format": {
"network_data_format": {
"inputs": {
"latent": {
"type": "noise",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"image_channels": 1,
"latent_channels": 1,
"discriminator_def": {
"_target_": "generative.networks.nets.PatchDiscriminator",
"_target_": "monai.networks.nets.patchgan_discriminator.PatchDiscriminator",
"spatial_dims": "@spatial_dims",
"num_layers_d": 3,
"num_channels": 32,
"channels": 32,
"in_channels": 1,
"out_channels": 1,
"norm": "INSTANCE"
},
"autoencoder_def": {
"_target_": "generative.networks.nets.AutoencoderKL",
"_target_": "monai.networks.nets.autoencoderkl.AutoencoderKL",
"spatial_dims": "@spatial_dims",
"in_channels": "@image_channels",
"out_channels": "@image_channels",
"latent_channels": "@latent_channels",
"num_channels": [
"channels": [
64,
128,
256
Expand All @@ -51,10 +51,11 @@
false
],
"with_encoder_nonlocal_attn": true,
"with_decoder_nonlocal_attn": true
"with_decoder_nonlocal_attn": true,
"include_fc": false
},
"perceptual_loss_def": {
"_target_": "generative.losses.PerceptualLoss",
"_target_": "monai.losses.perceptual.PerceptualLoss",
"spatial_dims": "@spatial_dims",
"network_type": "resnet50",
"pretrained": "@pretrained",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
64
],
"load_autoencoder_path": "$@bundle_root + '/models/model_autoencoder.pt'",
"load_autoencoder": "$@autoencoder_def.load_state_dict(torch.load(@load_autoencoder_path))",
"load_autoencoder": "$@autoencoder_def.load_old_state_dict(torch.load(@load_autoencoder_path))",
"autoencoder": "$@autoencoder_def.to(@device)",
"network_def": {
"_target_": "generative.networks.nets.DiffusionModelUNet",
"_target_": "monai.networks.nets.diffusion_model_unet.DiffusionModelUNet",
"spatial_dims": "@spatial_dims",
"in_channels": "@latent_channels",
"out_channels": "@latent_channels",
"num_channels": [
"channels": [
32,
64,
128,
Expand All @@ -38,7 +38,9 @@
32,
32
],
"num_res_blocks": 2
"num_res_blocks": 2,
"include_fc": false,
"use_combined_linear": false
},
"diffusion": "$@network_def.to(@device)",
"optimizer": {
Expand All @@ -56,7 +58,7 @@
},
"scale_factor": "$scripts.utils.compute_scale_factor(@autoencoder,@train#dataloader,@device)",
"noise_scheduler": {
"_target_": "generative.networks.schedulers.DDPMScheduler",
"_target_": "monai.networks.schedulers.ddpm.DDPMScheduler",
"_requires_": [
"@load_autoencoder"
],
Expand All @@ -70,7 +72,7 @@
},
"train": {
"inferer": {
"_target_": "generative.inferers.LatentDiffusionInferer",
"_target_": "monai.inferers.LatentDiffusionInferer",
"scheduler": "@noise_scheduler",
"scale_factor": "@scale_factor"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and

import torch
from generative.losses import PatchAdversarialLoss
from monai.losses.adversarial_loss import PatchAdversarialLoss

intensity_loss = torch.nn.L1Loss()
adv_loss = PatchAdversarialLoss(criterion="least_squares")
Expand Down
4 changes: 4 additions & 0 deletions models/model_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -1530,5 +1530,9 @@
"maisi_ct_generative_v0.3.6": {
"checksum": "3ce46e90e78e5bda1eac9db54adf4ccfcbc895a9",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/maisi_ct_generative/versions/0.3.6/files/maisi_ct_generative_v0.3.6.zip"
},
"brats_mri_axial_slices_generative_diffusion_v1.0.10": {
"checksum": "5eb72eb8d4b2b560baf51badf2255ce9a07dc2a7",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/brats_mri_axial_slices_generative_diffusion/versions/1.0.10/files/brats_mri_axial_slices_generative_diffusion_v1.0.10.zip"
}
}

0 comments on commit f8e7e9c

Please sign in to comment.