fix --input file.jpg
This commit is contained in:
parent
1d2d39dfa0
commit
44ee0769dd
@ -5,6 +5,7 @@ import typer
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from typer import Option
|
from typer import Option
|
||||||
|
from typer_config import use_json_config
|
||||||
|
|
||||||
from iopaint.const import *
|
from iopaint.const import *
|
||||||
from iopaint.runtime import setup_model_dir, dump_environment_info, check_device
|
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")
|
@typer_app.command(help="Start IOPaint server")
|
||||||
|
@use_json_config()
|
||||||
def start(
|
def start(
|
||||||
host: str = Option("127.0.0.1"),
|
host: str = Option("127.0.0.1"),
|
||||||
port: int = Option(8080),
|
port: int = Option(8080),
|
||||||
@ -163,9 +165,7 @@ def start(
|
|||||||
from iopaint.schema import ApiConfig
|
from iopaint.schema import ApiConfig
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
api = Api(
|
api_config = ApiConfig(
|
||||||
app,
|
|
||||||
ApiConfig(
|
|
||||||
host=host,
|
host=host,
|
||||||
port=port,
|
port=port,
|
||||||
model=model,
|
model=model,
|
||||||
@ -191,8 +191,9 @@ def start(
|
|||||||
gfpgan_device=gfpgan_device,
|
gfpgan_device=gfpgan_device,
|
||||||
enable_restoreformer=enable_restoreformer,
|
enable_restoreformer=enable_restoreformer,
|
||||||
restoreformer_device=restoreformer_device,
|
restoreformer_device=restoreformer_device,
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
print(api_config.model_dump_json(indent=4))
|
||||||
|
api = Api(app, api_config)
|
||||||
api.launch()
|
api.launch()
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +304,9 @@ def get_image_ext(img_bytes):
|
|||||||
def decode_base64_to_image(
|
def decode_base64_to_image(
|
||||||
encoding: str, gray=False
|
encoding: str, gray=False
|
||||||
) -> Tuple[np.array, Optional[np.array], Dict]:
|
) -> 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]
|
encoding = encoding.split(";")[1].split(",")[1]
|
||||||
image = Image.open(io.BytesIO(base64.b64decode(encoding)))
|
image = Image.open(io.BytesIO(base64.b64decode(encoding)))
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ def save_config(
|
|||||||
if str(config.output_dir) == ".":
|
if str(config.output_dir) == ".":
|
||||||
config.output_dir = None
|
config.output_dir = None
|
||||||
|
|
||||||
print(config)
|
print(config.model_dump_json(indent=4))
|
||||||
if config.input and not os.path.exists(config.input):
|
if config.input and not os.path.exists(config.input):
|
||||||
return "[Error] Input file or directory does not exist"
|
return "[Error] Input file or directory does not exist"
|
||||||
|
|
||||||
|
@ -19,5 +19,6 @@ piexif==1.1.3
|
|||||||
omegaconf
|
omegaconf
|
||||||
easydict
|
easydict
|
||||||
gradio
|
gradio
|
||||||
|
typer-config==1.4.0
|
||||||
|
|
||||||
Pillow==9.5.0 # for AnyText
|
Pillow==9.5.0 # for AnyText
|
||||||
|
Loading…
Reference in New Issue
Block a user