mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
cleanup upscaler settings
This commit is contained in:
@@ -188,10 +188,10 @@ def upscale_without_tiling(model, img):
|
||||
|
||||
|
||||
def esrgan_upscale(model, img):
|
||||
if opts.ESRGAN_tile == 0:
|
||||
if opts.upscaler_tile_size == 0:
|
||||
return upscale_without_tiling(model, img)
|
||||
|
||||
grid = images.split_grid(img, opts.ESRGAN_tile, opts.ESRGAN_tile, opts.ESRGAN_tile_overlap)
|
||||
grid = images.split_grid(img, opts.upscaler_tile_size, opts.upscaler_tile_size, opts.upscaler_tile_overlap)
|
||||
newtiles = []
|
||||
scale_factor = 1
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ class UpscalerRealESRGAN(Upscaler):
|
||||
model_path=info.local_data_path,
|
||||
model=info.model(),
|
||||
half=not opts.no_half and not opts.upcast_sampling,
|
||||
tile=opts.ESRGAN_tile,
|
||||
tile_pad=opts.ESRGAN_tile_overlap,
|
||||
tile=opts.upscaler_tile_size,
|
||||
tile_pad=opts.upscaler_tile_overlap,
|
||||
device=device,
|
||||
)
|
||||
self.models[info.local_data_path] = upsampler
|
||||
|
||||
@@ -39,8 +39,8 @@ class UpscalerSCUNet(Upscaler):
|
||||
def tiled_inference(img, model):
|
||||
# test the image tile by tile
|
||||
h, w = img.shape[2:]
|
||||
tile = opts.SCUNET_tile
|
||||
tile_overlap = opts.SCUNET_tile_overlap
|
||||
tile = opts.upscaler_tile_size
|
||||
tile_overlap = opts.upscaler_tile_overlap
|
||||
if tile == 0:
|
||||
return model(img)
|
||||
assert tile % 8 == 0, "tile size should be a multiple of window_size"
|
||||
@@ -72,7 +72,7 @@ class UpscalerSCUNet(Upscaler):
|
||||
model = self.load_model(selected_file)
|
||||
if model is None:
|
||||
return img
|
||||
tile = opts.SCUNET_tile
|
||||
tile = opts.upscaler_tile_size
|
||||
h, w = img.height, img.width
|
||||
np_img = np.array(img)
|
||||
np_img = np_img[:, :, ::-1] # RGB to BGR
|
||||
@@ -95,13 +95,3 @@ class UpscalerSCUNet(Upscaler):
|
||||
log.debug(f"Upscaler unloaded: type={self.name} model={selected_file}")
|
||||
devices.torch_gc(force=True)
|
||||
return img
|
||||
|
||||
|
||||
def on_ui_settings():
|
||||
import gradio as gr
|
||||
from modules import shared
|
||||
shared.opts.add_option("SCUNET_tile", shared.OptionInfo(256, "Tile size for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}, section=('postprocessing', "Postprocessing")).info("0 = no tiling"))
|
||||
shared.opts.add_option("SCUNET_tile_overlap", shared.OptionInfo(8, "Tile overlap for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}, section=('postprocessing', "Postprocessing")).info("Low values = visible seam"))
|
||||
|
||||
|
||||
script_callbacks.on_ui_settings(on_ui_settings)
|
||||
|
||||
@@ -85,8 +85,8 @@ def upscale(
|
||||
window_size=8,
|
||||
scale=4,
|
||||
):
|
||||
tile = tile or shared.opts.SWIN_tile
|
||||
tile_overlap = tile_overlap or shared.opts.SWIN_tile_overlap
|
||||
tile = tile or shared.opts.upscaler_tile_size
|
||||
tile_overlap = tile_overlap or shared.opts.upscaler_tile_overlap
|
||||
img = np.array(img)
|
||||
img = img[:, :, ::-1]
|
||||
img = np.moveaxis(img, 2, 0) / 255
|
||||
@@ -140,12 +140,3 @@ def inference(img, model, tile, tile_overlap, window_size, scale):
|
||||
progress.update(task, advance=1, description="Upscaling")
|
||||
output = E.div_(W)
|
||||
return output
|
||||
|
||||
|
||||
def on_ui_settings():
|
||||
import gradio as gr
|
||||
shared.opts.add_option("SWIN_tile", shared.OptionInfo(192, "Tile size for SwinIR upscaler", gr.Slider, {"minimum": 16, "maximum": 512, "step": 16}, section=('postprocessing', "Postprocessing")))
|
||||
shared.opts.add_option("SWIN_tile_overlap", shared.OptionInfo(8, "Tile overlap for SwinIR upscaler", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}, section=('postprocessing', "Postprocessing")))
|
||||
|
||||
|
||||
script_callbacks.on_ui_settings(on_ui_settings)
|
||||
|
||||
Reference in New Issue
Block a user