Instructions to use akshan-main/modular-sdxl-upscale with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use akshan-main/modular-sdxl-upscale with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("akshan-main/modular-sdxl-upscale") pipe = StableDiffusionControlNetPipeline.from_pretrained( "fill-in-base-model", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
Upload block.py with huggingface_hub
Browse files
block.py
CHANGED
|
@@ -9,6 +9,7 @@ References:
|
|
| 9 |
- Modular Diffusers: https://huggingface.co/docs/diffusers/main/en/modular_diffusers
|
| 10 |
"""
|
| 11 |
|
|
|
|
| 12 |
# ============================================================
|
| 13 |
# utils_tiling
|
| 14 |
# ============================================================
|
|
@@ -2229,16 +2230,24 @@ class UltimateSDUpscaleMultiDiffusionStep(ModularPipelineBlocks):
|
|
| 2229 |
image_latents = enc_state.get("image_latents")
|
| 2230 |
|
| 2231 |
# --- Re-compute timesteps for this pass's strength ---
|
| 2232 |
-
#
|
|
|
|
|
|
|
|
|
|
| 2233 |
pass_strength = block_state._current_pass_strength
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2234 |
_ts, _nsteps = retrieve_timesteps(
|
| 2235 |
components.scheduler,
|
| 2236 |
-
|
| 2237 |
components._execution_device,
|
| 2238 |
)
|
| 2239 |
from diffusers.modular_pipelines.stable_diffusion_xl.before_denoise import StableDiffusionXLImg2ImgSetTimestepsStep
|
| 2240 |
timesteps, num_inf_steps = StableDiffusionXLImg2ImgSetTimestepsStep.get_timesteps(
|
| 2241 |
-
components,
|
| 2242 |
)
|
| 2243 |
latent_timestep = timesteps[:1].repeat(block_state.batch_size * block_state.num_images_per_prompt)
|
| 2244 |
|
|
@@ -2572,7 +2581,7 @@ class UltimateSDUpscaleMultiDiffusionStep(ModularPipelineBlocks):
|
|
| 2572 |
|
| 2573 |
|
| 2574 |
# ============================================================
|
| 2575 |
-
#
|
| 2576 |
# ============================================================
|
| 2577 |
|
| 2578 |
# Copyright 2025 The HuggingFace Team. All rights reserved.
|
|
@@ -2779,3 +2788,4 @@ class UltimateSDUpscaleModularPipeline(StableDiffusionXLModularPipeline):
|
|
| 2779 |
"""
|
| 2780 |
|
| 2781 |
default_blocks_name = "UltimateSDUpscaleBlocks"
|
|
|
|
|
|
| 9 |
- Modular Diffusers: https://huggingface.co/docs/diffusers/main/en/modular_diffusers
|
| 10 |
"""
|
| 11 |
|
| 12 |
+
|
| 13 |
# ============================================================
|
| 14 |
# utils_tiling
|
| 15 |
# ============================================================
|
|
|
|
| 2230 |
image_latents = enc_state.get("image_latents")
|
| 2231 |
|
| 2232 |
# --- Re-compute timesteps for this pass's strength ---
|
| 2233 |
+
# The outer set_timesteps block overwrites num_inference_steps in state with
|
| 2234 |
+
# a strength-truncated value. To avoid double-truncation, we recover the
|
| 2235 |
+
# original step count: truncated = original - floor(original * strength),
|
| 2236 |
+
# so original = ceil(truncated / (1 - strength)). We clamp to at least 1.
|
| 2237 |
pass_strength = block_state._current_pass_strength
|
| 2238 |
+
truncated_steps = block_state.num_inference_steps
|
| 2239 |
+
if pass_strength < 1.0:
|
| 2240 |
+
original_steps = max(1, int(math.ceil(truncated_steps / (1.0 - pass_strength))))
|
| 2241 |
+
else:
|
| 2242 |
+
original_steps = truncated_steps
|
| 2243 |
_ts, _nsteps = retrieve_timesteps(
|
| 2244 |
components.scheduler,
|
| 2245 |
+
original_steps,
|
| 2246 |
components._execution_device,
|
| 2247 |
)
|
| 2248 |
from diffusers.modular_pipelines.stable_diffusion_xl.before_denoise import StableDiffusionXLImg2ImgSetTimestepsStep
|
| 2249 |
timesteps, num_inf_steps = StableDiffusionXLImg2ImgSetTimestepsStep.get_timesteps(
|
| 2250 |
+
components, original_steps, pass_strength, components._execution_device,
|
| 2251 |
)
|
| 2252 |
latent_timestep = timesteps[:1].repeat(block_state.batch_size * block_state.num_images_per_prompt)
|
| 2253 |
|
|
|
|
| 2581 |
|
| 2582 |
|
| 2583 |
# ============================================================
|
| 2584 |
+
# modular_blocks_ultimate_sd_upscale
|
| 2585 |
# ============================================================
|
| 2586 |
|
| 2587 |
# Copyright 2025 The HuggingFace Team. All rights reserved.
|
|
|
|
| 2788 |
"""
|
| 2789 |
|
| 2790 |
default_blocks_name = "UltimateSDUpscaleBlocks"
|
| 2791 |
+
|