Skip to content

Commit

Permalink
Merge pull request #70 from mrhan1993/main
Browse files Browse the repository at this point in the history
Add outpaint distance params to generation v2 apis.
  • Loading branch information
konieshadow authored Nov 28, 2023
2 parents fe0dc28 + 96bf3af commit 8c7795d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 8 additions & 4 deletions fooocusapi/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

if refiner_model_name == '':
refiner_model_name = 'None'
Expand Down
4 changes: 4 additions & 0 deletions fooocusapi/models_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8c7795d

Please sign in to comment.