From 18803db6ed83bf0521dc0e4792f0b528f26e12fd Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sat, 28 Jan 2023 22:48:53 -0600 Subject: [PATCH] fix(api): parse border and upscale in chain stages --- api/onnx_web/chain/blend_img2img.py | 2 +- api/onnx_web/serve.py | 10 ++++++++++ api/schema.yaml | 27 +++++++++++---------------- common/pipelines/example.json | 3 ++- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/api/onnx_web/chain/blend_img2img.py b/api/onnx_web/chain/blend_img2img.py index 8a00dfe7..930be4b2 100644 --- a/api/onnx_web/chain/blend_img2img.py +++ b/api/onnx_web/chain/blend_img2img.py @@ -49,6 +49,6 @@ def blend_img2img( ) output = result.images[0] - logger.info('final output image size', output.size) + logger.info('final output image size: %sx%s', output.width, output.height) return output diff --git a/api/onnx_web/serve.py b/api/onnx_web/serve.py index 9fcf414a..d5c6d802 100644 --- a/api/onnx_web/serve.py +++ b/api/onnx_web/serve.py @@ -573,14 +573,24 @@ def chain(): callback = chain_stages[stage_data.get('type')] kwargs = stage_data.get('params', {}) + print('stage', callback.__name__, kwargs) stage = StageParams( stage_data.get('name', callback.__name__), tile_size=int(kwargs.get('tile_size', SizeChart.auto)), outscale=int(kwargs.get('outscale', 1)), ) + # TODO: create Border from border + if 'border' in kwargs: + border = Border.even(int(kwargs.get('border'))) + kwargs['border'] = border + # TODO: create Upscale from upscale + if 'upscale' in kwargs: + upscale = UpscaleParams(params.model, params.provider) + kwargs['upscale'] = upscale + pipeline.append((callback, stage, kwargs)) # build and run chain pipeline diff --git a/api/schema.yaml b/api/schema.yaml index 4b031b09..079eaa95 100644 --- a/api/schema.yaml +++ b/api/schema.yaml @@ -39,22 +39,17 @@ $defs: type: type: string params: - type: object - properties: - args: - type: object - additionalProperties: False - patternProperties: - "^[-_A-Za-z]+$": - oneOf: - - type: number - - type: string - border: - $ref: "#/$defs/border_params" - image: - $ref: "#/$defs/image_params" - upscale: - $ref: "#/$defs/upscale_params" + allOf: + - $ref: "#/$defs/border_params" + - $ref: "#/$defs/image_params" + - $ref: "#/$defs/upscale_params" + - type: object + additionalProperties: False + patternProperties: + "^[-_A-Za-z]+$": + oneOf: + - type: number + - type: string request_chain: type: array diff --git a/common/pipelines/example.json b/common/pipelines/example.json index f7b284ff..63a82994 100644 --- a/common/pipelines/example.json +++ b/common/pipelines/example.json @@ -11,7 +11,8 @@ "name": "refine", "type": "blend-img2img", "params": { - "prompt": "a magical wizard in a robe fighting a dragon" + "prompt": "a magical wizard in a robe fighting a dragon", + "strength": 0.5 } }, {