From db13854380a1f833c435814f81b8812065d60714 Mon Sep 17 00:00:00 2001 From: mrhan1993 <50648276+mrhan1993@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:23:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?v2=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fooocusapi/api_utils.py | 12 ++++++++---- fooocusapi/models_v2.py | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fooocusapi/api_utils.py b/fooocusapi/api_utils.py index 96c30df..ee641c3 100644 --- a/fooocusapi/api_utils.py +++ b/fooocusapi/api_utils.py @@ -50,10 +50,14 @@ def req_to_params(req: Text2ImgRequest) -> ImageGenerationParams: outpaint_selections = [] if not (isinstance( req, ImgInpaintOrOutpaintRequest) or isinstance(req, ImgInpaintOrOutpaintRequestJson)) else [ s.value for s in req.outpaint_selections] - outpaint_distance_left = None if not isinstance(req, ImgInpaintOrOutpaintRequest) else req.outpaint_distance_left - outpaint_distance_right = None if not isinstance(req, ImgInpaintOrOutpaintRequest) else req.outpaint_distance_right - outpaint_distance_top = None if not isinstance(req, ImgInpaintOrOutpaintRequest) else req.outpaint_distance_top - outpaint_distance_bottom = None if not isinstance(req, ImgInpaintOrOutpaintRequest) else req.outpaint_distance_bottom + outpaint_distance_left = None if not (isinstance( + req, ImgInpaintOrOutpaintRequest) or isinstance(req, ImgInpaintOrOutpaintRequestJson)) else req.outpaint_distance_left + outpaint_distance_right = None if not (isinstance( + req, ImgInpaintOrOutpaintRequest) or isinstance(req, ImgInpaintOrOutpaintRequestJson)) else req.outpaint_distance_right + outpaint_distance_top = None if not (isinstance( + req, ImgInpaintOrOutpaintRequest) or isinstance(req, ImgInpaintOrOutpaintRequestJson)) else req.outpaint_distance_top + outpaint_distance_bottom = None if not (isinstance( + req, ImgInpaintOrOutpaintRequest) or isinstance(req, ImgInpaintOrOutpaintRequestJson)) else req.outpaint_distance_bottom aspect_ratios_selection = aspect_ratios_selection.replace('x', '×').replace('*', '×') if aspect_ratios_selection not in available_aspect_ratios: diff --git a/fooocusapi/models_v2.py b/fooocusapi/models_v2.py index 033c0c1..4d81812 100644 --- a/fooocusapi/models_v2.py +++ b/fooocusapi/models_v2.py @@ -11,6 +11,10 @@ class ImgInpaintOrOutpaintRequestJson(Text2ImgRequest): input_mask: str | None = Field(None, description="Inpaint or outpaint mask as base64") inpaint_additional_prompt: str | None = Field(None, description="Describe what you want to inpaint") outpaint_selections: List[OutpaintExpansion] = [] + outpaint_distance_left: int = Field(default=0, description="Set outpaint left distance"), + outpaint_distance_right: int = Field(default=0, description="Set outpaint right distance"), + outpaint_distance_top: int = Field(default=0, description="Set outpaint top distance"), + outpaint_distance_bottom: int = Field(default=0, description="Set outpaint bottom distance"), class ImagePromptJson(BaseModel): From f3ddfbbce16f890b27bc3f711f6d42ad388b508a Mon Sep 17 00:00:00 2001 From: mrhan1993 <50648276+mrhan1993@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:27:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/examples.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/examples.py b/examples/examples.py index 1a56be1..22cd752 100644 --- a/examples/examples.py +++ b/examples/examples.py @@ -146,7 +146,11 @@ class Config(): "input_image": "", "input_mask": None, "inpaint_additional_prompt": None, - "outpaint_selections": [] + "outpaint_selections": [], + "outpaint_distance_left": 0, + "outpaint_distance_right": 0, + "outpaint_distance_top": 0, + "outpaint_distance_bottom": 0, } img_prompt_params = {