Skip to content

Commit

Permalink
fix(api): use correct scale for background correction
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 17, 2023
1 parent b09feda commit 073ff8e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion api/onnx_web/upscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ def __init__(
self.platform = platform
self.half = half

def rescale(self, scale: int, outscale: int = 1):
return UpscaleParams(
self.upscale_model,
correction_model=self.correction_model,
scale=scale,
outscale=outscale,
denoise=self.denoise,
faces=self.faces,
platform=self.platform,
half=self.half,
)

def resize(self, size: Size) -> Size:
return Size(size.width * self.scale * self.outscale, size.height * self.scale * self.outscale)

Expand Down Expand Up @@ -165,7 +177,8 @@ def upscale_gfpgan(ctx: ServerContext, params: UpscaleParams, image, upsampler=N
return image

if upsampler is None:
upsampler = make_resrgan(ctx, params, tile=512)
bg_params = params.rescale(params.outscale)
upsampler = make_resrgan(ctx, bg_params, tile=512)

face_path = path.join(ctx.model_path, '%s.pth' % (params.correction_model))

Expand Down

0 comments on commit 073ff8e

Please sign in to comment.