Skip to content

Commit

Permalink
fix(api): parse border and upscale in chain stages
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 29, 2023
1 parent 151ebff commit 18803db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/onnx_web/chain/blend_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

10 changes: 10 additions & 0 deletions api/onnx_web/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 11 additions & 16 deletions api/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion common/pipelines/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
{
Expand Down

0 comments on commit 18803db

Please sign in to comment.