huge changes, inpainting in faces unit, change faces processing, change api, refactor, requires further testing
This commit is contained in:
@@ -3,6 +3,8 @@ from modules.upscaler import UpscalerData
|
||||
from dataclasses import dataclass
|
||||
from modules import shared
|
||||
from enum import Enum
|
||||
from scripts.faceswaplab_inpainting.faceswaplab_inpainting import InpaintingOptions
|
||||
from client_api import api_utils
|
||||
|
||||
|
||||
class InpaintingWhen(Enum):
|
||||
@@ -22,13 +24,10 @@ class PostProcessingOptions:
|
||||
scale: float = 1
|
||||
upscale_visibility: float = 0.5
|
||||
|
||||
inpainting_denoising_strengh: float = 0
|
||||
inpainting_prompt: str = ""
|
||||
inpainting_negative_prompt: str = ""
|
||||
inpainting_steps: int = 20
|
||||
inpainting_sampler: str = "Euler"
|
||||
inpainting_when: InpaintingWhen = InpaintingWhen.BEFORE_UPSCALING
|
||||
inpainting_model: str = "Current"
|
||||
|
||||
# (Don't use optional for this or gradio parsing will fail) :
|
||||
inpainting_options: InpaintingOptions = None
|
||||
|
||||
@property
|
||||
def upscaler(self) -> UpscalerData:
|
||||
@@ -43,3 +42,28 @@ class PostProcessingOptions:
|
||||
if face_restorer.name() == self.face_restorer_name:
|
||||
return face_restorer
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def from_api_dto(
|
||||
options: api_utils.PostProcessingOptions,
|
||||
) -> "PostProcessingOptions":
|
||||
"""
|
||||
Converts a PostProcessingOptions object from an API DTO (Data Transfer Object).
|
||||
|
||||
:param options: An object of api_utils.PostProcessingOptions representing the
|
||||
post-processing options as received from the API.
|
||||
:return: A PostProcessingOptions instance containing the translated values
|
||||
from the API DTO.
|
||||
"""
|
||||
return PostProcessingOptions(
|
||||
face_restorer_name=options.face_restorer_name,
|
||||
restorer_visibility=options.restorer_visibility,
|
||||
codeformer_weight=options.codeformer_weight,
|
||||
upscaler_name=options.upscaler_name,
|
||||
scale=options.scale,
|
||||
upscale_visibility=options.upscaler_visibility,
|
||||
inpainting_when=InpaintingWhen(options.inpainting_when.value),
|
||||
inpainting_options=InpaintingOptions.from_api_dto(
|
||||
options.inpainting_options
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user