MCPcopy Create free account
hub / github.com/SpenserCai/sd-webui-deoldify / deoldify_image

Function deoldify_image

scripts/api.py:26–39  ·  view source on GitHub ↗
(
        input_image: str = Body("",title="image input"),
        render_factor: int = Body(35,title="render factor"),
        artistic: bool = Body(False,title="artistic")
    )

Source from the content-addressed store, hash-verified

24def deoldify_api(_: gr.Blocks, app: FastAPI):
25 @app.post("/deoldify/image")
26 async def deoldify_image(
27 input_image: str = Body("",title="image input"),
28 render_factor: int = Body(35,title="render factor"),
29 artistic: bool = Body(False,title="artistic")
30 ):
31 vis = get_image_colorizer(root_folder=Path(paths_internal.models_path),render_factor=render_factor, artistic=artistic)
32 # 判断input_image是否是url
33 if input_image.startswith("http"):
34 img = vis._get_image_from_url(input_image)
35 else:
36 # 把base64转换成图片 PIL.Image
37 img = Image.open(BytesIO(base64.b64decode(input_image)))
38 outImg = vis.get_transformed_image_from_image(img, render_factor=render_factor)
39 return {"image": api.encode_pil_to_base64(outImg).decode("utf-8")}
40
41try:
42 import modules.script_callbacks as script_callbacks

Callers

nothing calls this directly

Calls 4

get_image_colorizerFunction · 0.85
_get_image_from_urlMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected