Improve speed with better scheduler
#4
by
patrickvonplaten
- opened
- image_transformation.py +3 -1
image_transformation.py
CHANGED
@@ -14,7 +14,7 @@ if is_vision_available():
|
|
14 |
from PIL import Image
|
15 |
|
16 |
if is_diffusers_available():
|
17 |
-
from diffusers import DiffusionPipeline
|
18 |
|
19 |
|
20 |
IMAGE_TRANSFORMATION_DESCRIPTION = (
|
@@ -50,6 +50,7 @@ class ImageTransformationTool(Tool):
|
|
50 |
self.device = get_default_device()
|
51 |
|
52 |
self.pipeline = DiffusionPipeline.from_pretrained(self.stable_diffusion)
|
|
|
53 |
|
54 |
self.pipeline.to(self.device)
|
55 |
if self.device.type == "cuda":
|
@@ -68,4 +69,5 @@ class ImageTransformationTool(Tool):
|
|
68 |
prompt + added_prompt,
|
69 |
image,
|
70 |
negative_prompt=negative_prompt,
|
|
|
71 |
).images[0]
|
|
|
14 |
from PIL import Image
|
15 |
|
16 |
if is_diffusers_available():
|
17 |
+
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
18 |
|
19 |
|
20 |
IMAGE_TRANSFORMATION_DESCRIPTION = (
|
|
|
50 |
self.device = get_default_device()
|
51 |
|
52 |
self.pipeline = DiffusionPipeline.from_pretrained(self.stable_diffusion)
|
53 |
+
self.pipeline.scheduler = DPMSolverMultistepScheduler.from_config(self.pipeline.scheduler.config)
|
54 |
|
55 |
self.pipeline.to(self.device)
|
56 |
if self.device.type == "cuda":
|
|
|
69 |
prompt + added_prompt,
|
70 |
image,
|
71 |
negative_prompt=negative_prompt,
|
72 |
+
num_inference_steps=40,
|
73 |
).images[0]
|