add gaussian blur on rpogress images
Browse files- handler.py +7 -1
handler.py
CHANGED
@@ -10,6 +10,8 @@ from pathlib import Path
|
|
10 |
from typing import Union
|
11 |
from concurrent.futures import ThreadPoolExecutor
|
12 |
import numpy as np
|
|
|
|
|
13 |
|
14 |
import torch
|
15 |
from diffusers import (
|
@@ -250,6 +252,10 @@ class EndpointHandler:
|
|
250 |
img_data = self.pipe.decode_latents(latents)
|
251 |
img_data = (img_data.squeeze() * 255).astype(np.uint8)
|
252 |
img = Image.fromarray(img_data, "RGB")
|
|
|
|
|
|
|
|
|
253 |
# print(img_data)
|
254 |
else:
|
255 |
# pil object
|
@@ -370,7 +376,7 @@ class EndpointHandler:
|
|
370 |
callback=lambda step, timestep, latents: self.progress_callback(
|
371 |
step, timestep, latents, request_id, "progress"
|
372 |
),
|
373 |
-
callback_steps=
|
374 |
# output_type="pt",
|
375 |
).images[0]
|
376 |
|
|
|
10 |
from typing import Union
|
11 |
from concurrent.futures import ThreadPoolExecutor
|
12 |
import numpy as np
|
13 |
+
from PIL import ImageFilter
|
14 |
+
|
15 |
|
16 |
import torch
|
17 |
from diffusers import (
|
|
|
252 |
img_data = self.pipe.decode_latents(latents)
|
253 |
img_data = (img_data.squeeze() * 255).astype(np.uint8)
|
254 |
img = Image.fromarray(img_data, "RGB")
|
255 |
+
|
256 |
+
# Apply a blur to the image
|
257 |
+
img = img.filter(ImageFilter.GaussianBlur(radius=5))
|
258 |
+
|
259 |
# print(img_data)
|
260 |
else:
|
261 |
# pil object
|
|
|
376 |
callback=lambda step, timestep, latents: self.progress_callback(
|
377 |
step, timestep, latents, request_id, "progress"
|
378 |
),
|
379 |
+
callback_steps=5, # The frequency at which the callback function is called.
|
380 |
# output_type="pt",
|
381 |
).images[0]
|
382 |
|