Skip to content

Commit 8ba1d08

Browse files
committed
update readme and input check
Signed-off-by: Pengfei Guo <[email protected]>
1 parent 08ccc1e commit 8ba1d08

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

generation/maisi/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ The information for the inference input, like body region and anatomy to generat
6868

6969
To generate images with substantial dimensions, such as 512 &times; 512 &times; 512 or larger, using GPUs with 80GB of memory, it is advisable to configure the `"num_splits"` parameter in [the auto-encoder configuration](./configs/config_maisi.json#L11-L37) to 16. This adjustment is crucial to avoid out-of-memory issues during inference.
7070

71+
#### Recommended spacing for different output sizes:
72+
73+
|`output_size`| Recommended `"spacing"`|
74+
|:-----:|:-----:|
75+
[256, 256, 256] | [1.5, 1.5, 1.5] |
76+
[512, 512, 128] | [0.8, 0.8, 2.5] |
77+
[512, 512, 512] | [1.0, 1.0, 1.0] |
78+
7179
#### Execute Inference:
7280
To run the inference script, please run:
7381
```bash

generation/maisi/scripts/infer_controlnet.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from monai.transforms import SaveImage
2424
from monai.utils import RankFilter
2525

26-
from .sample import ldm_conditional_sample_one_image
26+
from .sample import check_input, ldm_conditional_sample_one_image
2727
from .utils import define_instance, prepare_maisi_controlnet_json_dataloader, setup_ddp
2828

2929

@@ -150,10 +150,13 @@ def main():
150150
top_region_index_tensor = batch["top_region_index"].to(device)
151151
bottom_region_index_tensor = batch["bottom_region_index"].to(device)
152152
spacing_tensor = batch["spacing"].to(device)
153+
out_spacing = tuple((batch["spacing"].squeeze().numpy()/100).tolist())
153154
# get target dimension
154155
dim = batch["dim"]
155156
output_size = (dim[0].item(), dim[1].item(), dim[2].item())
156157
latent_shape = (args.latent_channels, output_size[0] // 4, output_size[1] // 4, output_size[2] // 4)
158+
# check if output_size and out_spacing are valid.
159+
check_input(None, None, None, output_size, out_spacing, None)
157160
# generate a single synthetic image using a latent diffusion model with controlnet.
158161
synthetic_images, _ = ldm_conditional_sample_one_image(
159162
autoencoder,

0 commit comments

Comments
 (0)