update
This commit is contained in:
@@ -15,7 +15,7 @@ router = APIRouter(tags=["inpaint"])
|
||||
@router.post("/inpaint")
|
||||
def inpaint(req: InpaintRequest) -> Dict[str, Any]:
|
||||
try:
|
||||
model_name = req.model_name or "sdxl_inpaint"
|
||||
model_name = req.model_name or "flux_fill"
|
||||
pil = b64_to_pil_image(req.image_b64).convert("RGB")
|
||||
|
||||
if req.mask_b64:
|
||||
@@ -24,13 +24,17 @@ def inpaint(req: InpaintRequest) -> Dict[str, Any]:
|
||||
mask = default_half_mask(pil)
|
||||
|
||||
predictor = get_inpaint_predictor(model_name)
|
||||
call_kw: Dict[str, Any] = {"strength": req.strength, "max_side": req.max_side}
|
||||
if req.guidance_scale is not None:
|
||||
call_kw["guidance_scale"] = req.guidance_scale
|
||||
if req.num_inference_steps is not None:
|
||||
call_kw["num_inference_steps"] = req.num_inference_steps
|
||||
out = predictor(
|
||||
pil,
|
||||
mask,
|
||||
req.prompt or "",
|
||||
req.negative_prompt or "",
|
||||
strength=req.strength,
|
||||
max_side=req.max_side,
|
||||
**call_kw,
|
||||
)
|
||||
|
||||
out_dir = OUTPUT_DIR / "inpaint"
|
||||
|
||||
@@ -43,19 +43,19 @@ def get_models() -> Dict[str, Any]:
|
||||
"mask2former": {"name": "Mask2Former (not implemented)"},
|
||||
},
|
||||
"inpaint": {
|
||||
"copy": {"name": "Copy (no-op)", "params": []},
|
||||
"sdxl_inpaint": {
|
||||
"name": "SDXL Inpaint",
|
||||
"params": [
|
||||
{"id": "prompt", "label": "提示词", "optional": True},
|
||||
],
|
||||
"flux_fill": {
|
||||
"name": "FLUX.1 Fill (default)",
|
||||
"params": [{"id": "prompt", "label": "prompt", "optional": True}],
|
||||
},
|
||||
"lama": {"name": "LaMa (Erase / Remove Object)", "params": []},
|
||||
"sdxl_inpaint": {
|
||||
"name": "sdxl_inpaint",
|
||||
"params": [{"id": "prompt", "label": "prompt", "optional": True}],
|
||||
},
|
||||
"lama": {"name": "lama", "params": []},
|
||||
"copy": {"name": "copy (debug)", "params": []},
|
||||
"controlnet": {
|
||||
"name": "ControlNet Inpaint (canny)",
|
||||
"params": [
|
||||
{"id": "prompt", "label": "提示词", "optional": True},
|
||||
],
|
||||
"name": "controlnet",
|
||||
"params": [{"id": "prompt", "label": "prompt", "optional": True}],
|
||||
},
|
||||
},
|
||||
"animation": {
|
||||
|
||||
@@ -52,6 +52,8 @@ class InpaintRequest(ImageInput):
|
||||
negative_prompt: Optional[str] = Field("", description="负向 prompt")
|
||||
mask_b64: Optional[str] = Field(None, description="mask PNG base64(可选)")
|
||||
max_side: int = Field(1024, ge=128, le=2048)
|
||||
guidance_scale: Optional[float] = Field(None, ge=0.0, le=200.0, description="扩散 CFG;不传则各后端默认")
|
||||
num_inference_steps: Optional[int] = Field(None, ge=1, le=150, description="采样步数;不传则各后端默认")
|
||||
|
||||
|
||||
class AnimateRequest(BaseModel):
|
||||
|
||||
@@ -76,6 +76,11 @@ def get_inpaint_predictor(model_name: str):
|
||||
_inpaint_cache[model_name] = _copy
|
||||
return _copy
|
||||
|
||||
if model_name == "flux_fill":
|
||||
pred, _ = build_inpaint_predictor(UnifiedInpaintConfig(backend=InpaintBackend.FLUX_FILL))
|
||||
_inpaint_cache[model_name] = pred
|
||||
return pred
|
||||
|
||||
if model_name == "sdxl_inpaint":
|
||||
pred, _ = build_inpaint_predictor(UnifiedInpaintConfig(backend=InpaintBackend.SDXL_INPAINT))
|
||||
_inpaint_cache[model_name] = pred
|
||||
|
||||
Reference in New Issue
Block a user