1
0
Fork 0
onnx-web/api/onnx_web/chain/persist_disk.py

29 lines
523 B
Python
Raw Normal View History

2023-01-28 23:09:19 +00:00
from logging import getLogger
2023-01-28 15:08:59 +00:00
from PIL import Image
from ..params import (
ImageParams,
StageParams,
)
from ..utils import (
base_join,
2023-01-28 15:08:59 +00:00
ServerContext,
)
2023-01-28 23:09:19 +00:00
logger = getLogger(__name__)
2023-01-28 15:08:59 +00:00
def persist_disk(
ctx: ServerContext,
_stage: StageParams,
_params: ImageParams,
2023-01-28 15:08:59 +00:00
source_image: Image.Image,
*,
output: str,
**kwargs,
2023-01-28 15:08:59 +00:00
) -> Image.Image:
dest = base_join(ctx.output_path, output)
source_image.save(dest)
2023-01-28 23:09:19 +00:00
logger.info('saved image to %s', dest)
2023-01-28 15:08:59 +00:00
return source_image