1
0
Fork 0

apply lint

This commit is contained in:
Sean Sube 2023-12-29 08:19:58 -06:00
parent ce90ffb0ee
commit 1035915d36
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
4 changed files with 19 additions and 9 deletions

View File

@ -32,7 +32,10 @@ class BlendDenoiseLocalStdStage(BaseStage):
logger.info("denoising source images")
return StageResult.from_arrays(
[remove_noise(source, threshold=strength)[0] for source in sources.as_numpy()]
[
remove_noise(source, threshold=strength)[0]
for source in sources.as_numpy()
]
)
@ -59,7 +62,9 @@ def replace_noise(region: np.ndarray, threshold: int, deviation: float, op = np.
diff = np.abs(central_pixel - region_normal)
# If the whole region is fairly consistent but the central pixel deviates significantly,
if diff > (region_deviation + threshold) and diff < (region_deviation + threshold * deviation):
if diff > (region_deviation + threshold) and diff < (
region_deviation + threshold * deviation
):
surrounding_pixels = region[region != central_pixel]
surrounding_median = op(surrounding_pixels)
# replace it with the median of surrounding pixels
@ -69,7 +74,12 @@ def replace_noise(region: np.ndarray, threshold: int, deviation: float, op = np.
return False
def remove_noise(image: np.ndarray, threshold: int, deviation: float, region_size: Tuple[int, int] = (6, 6)):
def remove_noise(
image: np.ndarray,
threshold: int,
deviation: float,
region_size: Tuple[int, int] = (6, 6),
):
# Create a copy of the original image to store the result
result_image = np.copy(image)
result_mask = np.zeros_like(image)

View File

@ -5,9 +5,9 @@ import numpy as np
import torch
from diffusers import OnnxRuntimeModel
from diffusers.pipelines.onnx_utils import ORT_TO_NP_TYPE
from ..version_safe_diffusers import AutoencoderKLOutput, DecoderOutput
from ...server import ServerContext
from ..version_safe_diffusers import AutoencoderKLOutput, DecoderOutput
logger = getLogger(__name__)

View File

@ -37,8 +37,8 @@ else:
if is_diffusers_0_24:
from diffusers.models.modeling_outputs import AutoencoderKLOutput
from diffusers.models.autoencoders.vae import DecoderOutput
from diffusers.models.modeling_outputs import AutoencoderKLOutput
else:
from diffusers.models.autoencoder_kl import AutoencoderKLOutput
from diffusers.models.vae import DecoderOutput