Skip to content

Conversation

@minettekaum
Copy link
Contributor

Description

The enhancer algorithms realesrgan_upscale and img2img_denoise were added to Pruna.

  • The realesrgan_upscale algorithm is in file src/pruna/algorithms/denoise.py and tests are in tests/algorithms/testers/upscale.py.

  • The img2img_denoise algorithm is in file src/pruna/algorithms/denoise.pyand tests are in tests/algorithms/testers/denoise.py

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

The tests in the algorithms' respective test files have passed.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment @cursor review or bugbot run to trigger another review on this PR

"""
output = self.original_pipe_call(*args, **kwargs)
enhanced_images = []
for image in output.images:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing null check before accessing output images

In UpscaleHelper._wrapped_pipe_call, output.images is accessed directly without checking if output is None or has an images attribute. This contrasts with DenoiseHelper._wrapped_pipe_call in denoise.py, which properly guards with if output is None or not hasattr(output, "images") or not output.images: before accessing the images. If the pipeline returns an unexpected output (e.g., None or an object without images), this will raise an AttributeError or TypeError at runtime.

Fix in Cursor Fix in Web

tile_pad=smash_config["tile_pad"],
pre_pad=smash_config["pre_pad"],
half=not smash_config["fp32"],
gpu_id=0,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Hardcoded GPU device ignores CPU and multi-GPU configuration

The RealESRGANer is instantiated with gpu_id=0 hardcoded, but the class declares runs_on: list[str] = ["cpu", "cuda", "accelerate"], claiming CPU and multi-GPU support. This means the algorithm will always attempt to use GPU 0 regardless of smash_config.device, potentially failing when the user configures CPU mode (which requires gpu_id=None) or a different GPU. This contrasts with denoise.py which properly uses .to(smash_config.device) to respect the device configuration.

Additional Locations (1)

Fix in Cursor Fix in Web

@minettekaum minettekaum changed the title Feat/enhancers algorithms - realesrgan_upscale and img2img_denoise Feat: enhancers algorithms - realesrgan_upscale and img2img_denoise Dec 19, 2025
@minettekaum minettekaum changed the title Feat: enhancers algorithms - realesrgan_upscale and img2img_denoise Feat: enhancers algorithms Dec 19, 2025
@minettekaum minettekaum changed the title Feat: enhancers algorithms Feat: add enhancers algorithms Dec 19, 2025
@minettekaum minettekaum force-pushed the feat/enhancers-algorithms branch from 4d6f3d2 to c272862 Compare December 19, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants