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

34 lines
592 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 ..device_pool import (
JobContext,
)
2023-01-28 15:08:59 +00:00
from ..params import (
ImageParams,
StageParams,
)
from ..output import (
save_image,
)
2023-01-28 15:08:59 +00:00
from ..utils import (
ServerContext,
)
2023-01-28 23:09:19 +00:00
logger = getLogger(__name__)
2023-01-28 15:08:59 +00:00
def persist_disk(
_job: JobContext,
2023-01-28 15:08:59 +00:00
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 = save_image(ctx, output, source_image)
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