fix(api): write border and upscale to params file
This commit is contained in:
parent
c19f39f9b4
commit
b1eec6907a
|
@ -21,22 +21,25 @@ def json_params(
|
|||
upscale: Optional[UpscaleParams] = None,
|
||||
border: Optional[Border] = None,
|
||||
) -> Any:
|
||||
json = {
|
||||
'output': output,
|
||||
'params': params.tojson(),
|
||||
}
|
||||
|
||||
if upscale is not None and border is not None:
|
||||
size = upscale.resize(size.add_border(border))
|
||||
|
||||
if upscale is not None:
|
||||
json['upscale'] = upscale.tojson()
|
||||
size = upscale.resize(size)
|
||||
|
||||
if border is not None:
|
||||
json['border'] = border.tojson()
|
||||
size = size.add_border(border)
|
||||
|
||||
return {
|
||||
'border': border.tojson(),
|
||||
'output': output,
|
||||
'params': params.tojson(),
|
||||
'size': size.tojson(),
|
||||
'upscale': upscale.tojson(),
|
||||
}
|
||||
json['size'] = size
|
||||
|
||||
return
|
||||
|
||||
|
||||
def save_image(ctx: ServerContext, output: str, image: Image.Image) -> str:
|
||||
|
|
|
@ -28,6 +28,14 @@ class Border:
|
|||
def __str__(self) -> str:
|
||||
return '%s %s %s %s' % (self.left, self.top, self.right, self.bottom)
|
||||
|
||||
def tojson(self):
|
||||
return {
|
||||
'left': self.left,
|
||||
'right': self.right,
|
||||
'top': self.top,
|
||||
'bottom': self.bottom,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def even(cls, all: int):
|
||||
return Border(all, all, all, all)
|
||||
|
@ -149,3 +157,11 @@ class UpscaleParams():
|
|||
|
||||
def resize(self, size: Size) -> Size:
|
||||
return Size(size.width * self.outscale, size.height * self.outscale)
|
||||
|
||||
def tojson(self):
|
||||
return {
|
||||
'model': self.upscale_model,
|
||||
'scale': self.scale,
|
||||
'outscale': self.outscale,
|
||||
# TODO: add more
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue