2023-11-19 00:13:13 +00:00
|
|
|
from typing import Optional
|
2023-01-27 23:08:36 +00:00
|
|
|
|
2023-02-05 13:53:26 +00:00
|
|
|
from PIL import Image
|
|
|
|
|
2023-11-18 23:18:23 +00:00
|
|
|
from ..params import ImageParams, Size, SizeChart, StageParams
|
|
|
|
from ..server.context import ServerContext
|
|
|
|
from ..worker.context import WorkerContext
|
2023-11-19 00:13:13 +00:00
|
|
|
from .result import StageResult
|
2023-01-27 23:08:36 +00:00
|
|
|
|
2023-01-28 23:09:19 +00:00
|
|
|
|
2023-11-18 23:18:23 +00:00
|
|
|
class BaseStage:
|
|
|
|
max_tile = SizeChart.auto
|
2023-01-27 23:08:36 +00:00
|
|
|
|
2023-07-01 02:42:24 +00:00
|
|
|
def run(
|
|
|
|
self,
|
2023-11-18 23:18:23 +00:00
|
|
|
_worker: WorkerContext,
|
|
|
|
_server: ServerContext,
|
|
|
|
_stage: StageParams,
|
|
|
|
_params: ImageParams,
|
2023-11-19 00:08:38 +00:00
|
|
|
_sources: StageResult,
|
2023-12-03 18:53:50 +00:00
|
|
|
*,
|
2023-11-18 23:18:23 +00:00
|
|
|
stage_source: Optional[Image.Image] = None,
|
|
|
|
**kwargs,
|
|
|
|
) -> StageResult:
|
|
|
|
raise NotImplementedError() # noqa
|
|
|
|
|
|
|
|
def steps(
|
2023-02-05 13:53:26 +00:00
|
|
|
self,
|
2023-11-18 23:18:23 +00:00
|
|
|
_params: ImageParams,
|
|
|
|
_size: Size,
|
|
|
|
) -> int:
|
|
|
|
return 1 # noqa
|
2023-06-30 04:36:45 +00:00
|
|
|
|
2023-11-18 23:18:23 +00:00
|
|
|
def outputs(
|
|
|
|
self,
|
|
|
|
_params: ImageParams,
|
|
|
|
sources: int,
|
|
|
|
) -> int:
|
|
|
|
return sources
|