Skip to content

Commit

Permalink
Merge pull request AUTOMATIC1111#5179 from kaneda2004/master
Browse files Browse the repository at this point in the history
Update SD Upscaler to include user selectable Scale Factor
  • Loading branch information
AUTOMATIC1111 authored Dec 10, 2022
2 parents 8923785 + 950d9c7 commit 854bb0b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/sd_upscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ def show(self, is_img2img):
return is_img2img

def ui(self, is_img2img):
info = gr.HTML("<p style=\"margin-bottom:0.75em\">Will upscale the image to twice the dimensions; use width and height sliders to set tile size</p>")
info = gr.HTML("<p style=\"margin-bottom:0.75em\">Will upscale the image by the selected scale factor; use width and height sliders to set tile size</p>")
overlap = gr.Slider(minimum=0, maximum=256, step=16, label='Tile overlap', value=64)
scale_factor = gr.Slider(minimum=1, maximum=4, step=1, label='Scale Factor', value=2)
upscaler_index = gr.Radio(label='Upscaler', choices=[x.name for x in shared.sd_upscalers], value=shared.sd_upscalers[0].name, type="index")

return [info, overlap, upscaler_index]
return [info, overlap, upscaler_index, scale_factor]

def run(self, p, _, overlap, upscaler_index):
def run(self, p, _, overlap, upscaler_index, scale_factor):
processing.fix_seed(p)
upscaler = shared.sd_upscalers[upscaler_index]

Expand All @@ -34,9 +35,9 @@ def run(self, p, _, overlap, upscaler_index):
seed = p.seed

init_img = p.init_images[0]
if(upscaler.name != "None"):
img = upscaler.scaler.upscale(init_img, 2, upscaler.data_path)

if (upscaler.name != "None"):
img = upscaler.scaler.upscale(init_img, scale_factor, upscaler.data_path)
else:
img = init_img

Expand Down Expand Up @@ -69,7 +70,7 @@ def run(self, p, _, overlap, upscaler_index):
work_results = []
for i in range(batch_count):
p.batch_size = batch_size
p.init_images = work[i*batch_size:(i+1)*batch_size]
p.init_images = work[i * batch_size:(i + 1) * batch_size]

state.job = f"Batch {i + 1 + n * batch_count} out of {state.job_count}"
processed = processing.process_images(p)
Expand Down

0 comments on commit 854bb0b

Please sign in to comment.