Instructions to use diffusers/sd-vae-ft-mse with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use diffusers/sd-vae-ft-mse with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("diffusers/sd-vae-ft-mse", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse files- handler.py +3 -4
handler.py
CHANGED
|
@@ -7,10 +7,9 @@ from diffusers.image_processor import VaeImageProcessor
|
|
| 7 |
|
| 8 |
class EndpointHandler:
|
| 9 |
def __init__(self, path=""):
|
| 10 |
-
|
| 11 |
-
self.
|
| 12 |
-
self.
|
| 13 |
-
self.vae = AutoencoderKL.from_pretrained(path, **kwargs).to(self.device).eval()
|
| 14 |
|
| 15 |
self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
|
| 16 |
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
|
|
|
|
| 7 |
|
| 8 |
class EndpointHandler:
|
| 9 |
def __init__(self, path=""):
|
| 10 |
+
self.device = "cuda"
|
| 11 |
+
self.dtype = torch.float16
|
| 12 |
+
self.vae = AutoencoderKL.from_pretrained(path, torch_dtype=self.dtype).to(self.device, self.dtype).eval()
|
|
|
|
| 13 |
|
| 14 |
self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
|
| 15 |
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
|