|
18 | 18 | from diffusers import AutoencoderKL, DDPMScheduler, PNDMScheduler, StableDiffusionPipeline, UNet2DConditionModel |
19 | 19 | from diffusers.optimization import get_scheduler |
20 | 20 | from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker |
21 | | -from diffusers.utils import PIL_INTERPOLATION |
22 | 21 | from huggingface_hub import HfFolder, Repository, whoami |
23 | 22 | from PIL import Image |
24 | 23 | from torchvision import transforms |
25 | 24 | from tqdm.auto import tqdm |
26 | 25 | from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer |
27 | 26 |
|
| 27 | +# TODO: remove and import from diffusers.utils when the new version of diffusers is released |
| 28 | +from packaging import version |
| 29 | +import PIL |
| 30 | +if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): |
| 31 | + PIL_INTERPOLATION = { |
| 32 | + "linear": PIL.Image.Resampling.BILINEAR, |
| 33 | + "bilinear": PIL.Image.Resampling.BILINEAR, |
| 34 | + "bicubic": PIL.Image.Resampling.BICUBIC, |
| 35 | + "lanczos": PIL.Image.Resampling.LANCZOS, |
| 36 | + "nearest": PIL.Image.Resampling.NEAREST, |
| 37 | + } |
| 38 | +else: |
| 39 | + PIL_INTERPOLATION = { |
| 40 | + "linear": PIL.Image.LINEAR, |
| 41 | + "bilinear": PIL.Image.BILINEAR, |
| 42 | + "bicubic": PIL.Image.BICUBIC, |
| 43 | + "lanczos": PIL.Image.LANCZOS, |
| 44 | + "nearest": PIL.Image.NEAREST, |
| 45 | + } |
| 46 | +# ------------------------------------------------------------------------------ |
| 47 | + |
28 | 48 |
|
29 | 49 | logger = get_logger(__name__) |
30 | 50 |
|
|
0 commit comments