Skip to content

Commit

Permalink
Workaround for OmniSR not working with DirectML
Browse files Browse the repository at this point in the history
Make custom checkpoint resolution work with upscale tile size
  • Loading branch information
Acly committed Jan 5, 2024
1 parent 70fdf8b commit a0ffae9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ai_diffusion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ async def connect(url=default_url):
client.fast_upscaler = {
n: _find_upscaler(client.upscalers, UpscalerName.fast_x(n).value) for n in [2, 3, 4]
}
if client.device_info.type == "privateuseone": # DirectML: OmniSR makes Comfy crash (?)
client.fast_upscaler = {n: client.default_upscaler for n in [2, 3, 4]}

# Retrieve LCM LoRA models
client.lcm_model = {
Expand Down
4 changes: 2 additions & 2 deletions ai_diffusion/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Settings(QObject):
"Generation Resolution",
1.0,
"Scaling factor for image generation. Values below 1.0 improve performance when working"
" with high resolution canvas.",
" on high resolution canvas.",
)

max_pixel_count: int
Expand All @@ -186,7 +186,7 @@ class Settings(QObject):
},
PerformancePreset.high: {
"batch_size": 8,
"max_pixel_count": 8,
"max_pixel_count": 24,
},
}

Expand Down
4 changes: 2 additions & 2 deletions ai_diffusion/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,13 +1114,13 @@ def __init__(self):
advanced_layout.addWidget(self._batch_size)

self._resolution_multiplier = SliderSetting(
Settings._resolution_multiplier, self._advanced, 0.3, 2.0, "{:.1f}x"
Settings._resolution_multiplier, self._advanced, 0.3, 1.5, "{:.1f}x"
)
self._resolution_multiplier.value_changed.connect(self.write)
advanced_layout.addWidget(self._resolution_multiplier)

self._max_pixel_count = SpinBoxSetting(
Settings._max_pixel_count, self._advanced, 1, 50, 1, " MP"
Settings._max_pixel_count, self._advanced, 1, 99, 1, " MP"
)
self._max_pixel_count.value_changed.connect(self.write)
advanced_layout.addWidget(self._max_pixel_count)
Expand Down
4 changes: 3 additions & 1 deletion ai_diffusion/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,9 @@ def upscale_tiled(
sd_ver = resolve_sd_version(style, comfy)
cond = Conditioning("4k uhd")
target_extent = image.extent * factor
if sd_ver is SDVersion.sd15:
if style.preferred_resolution > 0:
tile_extent = Extent(style.preferred_resolution, style.preferred_resolution)
elif sd_ver is SDVersion.sd15:
tile_count = target_extent.longest_side / 768
tile_extent = (target_extent * (1 / tile_count)).multiple_of(8)
else: # SDXL
Expand Down

0 comments on commit a0ffae9

Please sign in to comment.