mirror of
https://github.com/Haoming02/sd-webui-old-photo-restoration.git
synced 2026-01-26 11:19:51 +00:00
29 lines
865 B
Python
29 lines
865 B
Python
import gradio as gr
|
|
from fastapi import Body, FastAPI
|
|
|
|
from modules.api import api
|
|
from modules.api.models import *
|
|
from modules.script_callbacks import on_app_started
|
|
from scripts.bopb2l_main import main
|
|
|
|
|
|
def bop_api(_: gr.Blocks, app: FastAPI):
|
|
|
|
@app.post("/bopb2l/restore")
|
|
async def old_photo_restoration(
|
|
image: str = Body("", title="input image"),
|
|
scratch: bool = Body(False, title="process scratch"),
|
|
hr: bool = Body(False, title="high resolution"),
|
|
face_res: bool = Body(False, title="face restore"),
|
|
cpu: bool = Body(False, title="force CPU"),
|
|
):
|
|
if not image:
|
|
return
|
|
|
|
input_image = api.decode_base64_to_image(image)
|
|
img = main(input_image, scratch, hr, face_res, cpu)
|
|
return {"image": api.encode_pil_to_base64(img).decode("utf-8")}
|
|
|
|
|
|
on_app_started(bop_api)
|