Resize a PIL image. Both height and width will be downscaled to the next integer multiple of `vae_scale_factor`
(self, images: PIL.Image.Image)
| 102 | return (images / 2 + 0.5).clamp(0, 1) |
| 103 | |
| 104 | def resize(self, images: PIL.Image.Image) -> PIL.Image.Image: |
| 105 | """ |
| 106 | Resize a PIL image. Both height and width will be downscaled to the next integer multiple of `vae_scale_factor` |
| 107 | """ |
| 108 | w, h = images.size |
| 109 | w, h = (x - x % self.config.vae_scale_factor for x in (w, h)) # resize to integer multiple of vae_scale_factor |
| 110 | images = images.resize((w, h), resample=PIL_INTERPOLATION[self.config.resample]) |
| 111 | return images |
| 112 | |
| 113 | def preprocess( |
| 114 | self, |
no outgoing calls