wip, add nsfw option due to perf, still some mypy warnings

This commit is contained in:
Tran Xen
2023-08-16 01:11:02 +02:00
parent f9fc0bbff1
commit afcfc7d255
20 changed files with 123 additions and 89 deletions
@@ -1,3 +1,4 @@
from typing import Optional
from modules.face_restoration import FaceRestoration
from modules.upscaler import UpscalerData
from dataclasses import dataclass
@@ -27,17 +28,17 @@ class PostProcessingOptions:
inpainting_when: InpaintingWhen = InpaintingWhen.BEFORE_UPSCALING
# (Don't use optional for this or gradio parsing will fail) :
inpainting_options: InpaintingOptions = None
inpainting_options: InpaintingOptions = None # type: ignore
@property
def upscaler(self) -> UpscalerData:
def upscaler(self) -> Optional[UpscalerData]:
for upscaler in shared.sd_upscalers:
if upscaler.name == self.upscaler_name:
return upscaler
return None
@property
def face_restorer(self) -> FaceRestoration:
def face_restorer(self) -> Optional[FaceRestoration]:
for face_restorer in shared.face_restorers:
if face_restorer.name() == self.face_restorer_name:
return face_restorer
@@ -17,7 +17,7 @@ def upscale_img(image: PILImage, pp_options: PostProcessingOptions) -> PILImage:
pp_options.scale,
)
result_image = pp_options.upscaler.scaler.upscale(
image, pp_options.scale, pp_options.upscaler.data_path
image, pp_options.scale, pp_options.upscaler.data_path # type: ignore
)
# FIXME : Could be better (managing images whose dimensions are not multiples of 16)