fix --input file.jpg

This commit is contained in:
Qing 2024-01-31 22:10:13 +08:00
parent 1d2d39dfa0
commit 44ee0769dd
4 changed files with 35 additions and 31 deletions

View File

@ -5,6 +5,7 @@ import typer
from fastapi import FastAPI
from loguru import logger
from typer import Option
from typer_config import use_json_config
from iopaint.const import *
from iopaint.runtime import setup_model_dir, dump_environment_info, check_device
@ -92,6 +93,7 @@ def run(
@typer_app.command(help="Start IOPaint server")
@use_json_config()
def start(
host: str = Option("127.0.0.1"),
port: int = Option(8080),
@ -163,9 +165,7 @@ def start(
from iopaint.schema import ApiConfig
app = FastAPI()
api = Api(
app,
ApiConfig(
api_config = ApiConfig(
host=host,
port=port,
model=model,
@ -191,8 +191,9 @@ def start(
gfpgan_device=gfpgan_device,
enable_restoreformer=enable_restoreformer,
restoreformer_device=restoreformer_device,
),
)
print(api_config.model_dump_json(indent=4))
api = Api(app, api_config)
api.launch()

View File

@ -304,7 +304,9 @@ def get_image_ext(img_bytes):
def decode_base64_to_image(
encoding: str, gray=False
) -> Tuple[np.array, Optional[np.array], Dict]:
if encoding.startswith("data:image/"):
if encoding.startswith("data:image/") or encoding.startswith(
"data:application/octet-stream;base64,"
):
encoding = encoding.split(";")[1].split(",")[1]
image = Image.open(io.BytesIO(base64.b64decode(encoding)))

View File

@ -60,7 +60,7 @@ def save_config(
if str(config.output_dir) == ".":
config.output_dir = None
print(config)
print(config.model_dump_json(indent=4))
if config.input and not os.path.exists(config.input):
return "[Error] Input file or directory does not exist"

View File

@ -19,5 +19,6 @@ piexif==1.1.3
omegaconf
easydict
gradio
typer-config==1.4.0
Pillow==9.5.0 # for AnyText