Skip to content

Commit

Permalink
Modification of metadata to remove generative package requirement, no…
Browse files Browse the repository at this point in the history
… longer necessary. On inference, modification of the entry point from save_jpg to run to allow for run to be called alone, and truncation of loading statements which are too long. Modification of the README to include command example changes.
  • Loading branch information
Virginia committed Dec 12, 2024
1 parent fe87cb4 commit 315276b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"with_decoder_nonlocal_attn": false
},
"load_autoencoder_path": "$@model_dir + '/autoencoder.pth'",
"load_autoencoder": "$@autoencoder_def.load_old_state_dict(torch.load(@load_autoencoder_path)) if bool(@load_old) else @autoencoder_def.load_state_dict(torch.load(@load_autoencoder_path))",
"load_autoencoder_func": "$@autoencoder_def.load_old_state_dict if bool(@load_old) else @autoencoder_def.load_state_dict",
"load_autoencoder": "$@load_autoencoder_func(torch.load(@load_autoencoder_path))",
"autoencoder": "$@autoencoder_def.to(@device)",
"diffusion_def": {
"_target_": "monai.networks.nets.DiffusionModelUNet",
Expand Down Expand Up @@ -76,7 +77,8 @@
"cross_attention_dim": 1024
},
"load_diffusion_path": "$@model_dir + '/diffusion_model.pth'",
"load_diffusion": "$@diffusion_def.load_old_state_dict(torch.load(@load_diffusion_path)) if bool(@load_old) else @diffusion_def.load_state_dict(torch.load(@load_diffusion_path))",
"load_diffusion_func": "$@diffusion_def.load_old_state_dict if bool(@load_old) else @diffusion_def.load_state_dict",
"load_diffusion": "$@load_diffusion_func(torch.load(@load_diffusion_path))",
"diffusion": "$@diffusion_def.to(@device)",
"scheduler": {
"_target_": "monai.networks.schedulers.DDIMScheduler",
Expand All @@ -103,6 +105,6 @@
"_requires_": "@create_output_dir",
"output_dir": "@output_dir"
},
"save_jpg": "[email protected](@sample, @out_file)",
"run": "[email protected](@sample, @out_file)",
"save": "$torch.save(@sample, @output_dir + '/' + @out_file + '.pt')"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"numpy_version": "1.22.4",
"optional_packages_version": {
"nibabel": "4.0.1",
"generative": "0.1.0",
"transformers": "4.26.1"
},
"task": "Chest X-ray image synthesis",
Expand All @@ -26,7 +25,7 @@
"format": "magnitude",
"modality": "CXR",
"num_channels": 3,
"spatial_shape": [
"spatial_shape": [77,
64,
64
],
Expand Down
10 changes: 5 additions & 5 deletions models/cxr_image_synthesis_latent_diffusion_model/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ the image sticks to a given text input (the common range is between 1-21).
Examples:

```shell
$ python -m monai.bundle run save_jpg --config_file configs/inference.json --prompt "Big right-sided pleural effusion" --guidance_scale 7.0
$ python -m monai.bundle run --config_file configs/inference.json --prompt "Big right-sided pleural effusion" --guidance_scale 7.0
```

```shell
$ python -m monai.bundle run save_jpg --config_file configs/inference.json --prompt "Small right-sided pleural effusion" --guidance_scale 7.0
$ python -m monai.bundle run --config_file configs/inference.json --prompt "Small right-sided pleural effusion" --guidance_scale 7.0
```

```shell
$ python -m monai.bundle run save_jpg --config_file configs/inference.json --prompt "Bilateral pleural effusion" --guidance_scale 7.0
$ python -m monai.bundle run --config_file configs/inference.json --prompt "Bilateral pleural effusion" --guidance_scale 7.0
```

```shell
$ python -m monai.bundle run save_jpg --config_file configs/inference.json --prompt "Cardiomegaly" --guidance_scale 7.0
$ python -m monai.bundle run --config_file configs/inference.json --prompt "Cardiomegaly" --guidance_scale 7.0
```

## Using a new version of the model
Expand All @@ -58,7 +58,7 @@ to avoid the function load_old_state_dict being called instead of load_state_dic
required to load the checkpoint from the original GenerativeModels repository.

```shell
$ python -m monai.bundle run save_jpg --config_file configs/inference.json --prompt "Pleural effusion." --guidance_scale 7.0 --load_old 0
$ python -m monai.bundle run --config_file configs/inference.json --prompt "Pleural effusion." --guidance_scale 7.0 --load_old 0
```

## References
Expand Down

0 comments on commit 315276b

Please sign in to comment.