home · contact · privacy
Switch to faster torch_dtype=float16 for Stable Diffusion pipelines.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 19 Aug 2024 02:55:18 +0000 (04:55 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 19 Aug 2024 02:55:18 +0000 (04:55 +0200)
stable/core.py

index 5612ab2105cf2719ae3761271f05e078ce71dfce..e85f5171c1ade8389a458e28f5268bfff422f6cb 100644 (file)
@@ -3,7 +3,7 @@ from logging import (Formatter as LogFormatter, captureWarnings,
 from os.path import basename
 from diffusers import StableDiffusionPipeline
 from diffusers.utils import logging
-from torch import Generator
+from torch import Generator, float16
 from exiftool import ExifToolHelper  # type: ignore
 
 SAFETY_CHECKER_WARNING_PATTERN = 'You have disabled the safety checker'
@@ -38,8 +38,8 @@ class ImageMaker:
                 FilterOut(SAFETY_CHECKER_WARNING_PATTERN))
         captureWarnings(True)
         logging.disable_progress_bar()
-        self.pipe = StableDiffusionPipeline.from_single_file(
-                model_path, local_files_only=True)
+        self.pipe = StableDiffusionPipeline.from_single_file(model_path, torch_dtype=float16,
+                                                             local_files_only=True)
         self.pipe.to('cuda')
         self.generator = Generator()
         print('PIPELINE READY\n')