Skip to content

Commit 62aa0a6

Browse files
committed
update
1 parent 4145f6b commit 62aa0a6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/diffusers/pipelines/sana/pipeline_sana_controlnet.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import inspect
1717
import re
1818
import urllib.parse as ul
19+
import warnings
1920
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
2021

2122
import torch
@@ -1053,7 +1054,14 @@ def __call__(
10531054
image = latents
10541055
else:
10551056
latents = latents.to(self.vae.dtype)
1056-
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
1057+
try:
1058+
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
1059+
except torch.cuda.OutOfMemoryError as e:
1060+
warnings.warn(
1061+
f"{e}. \n"
1062+
f"Try to use VAE tiling for large images. For example: \n"
1063+
f"pipe.vae.enable_tiling(tile_sample_min_width=512, tile_sample_min_height=512)"
1064+
)
10571065
if use_resolution_binning:
10581066
image = self.image_processor.resize_and_crop_tensor(image, orig_width, orig_height)
10591067

0 commit comments

Comments
 (0)