Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when specifying size on cpu mode #472

Closed
SteHun opened this issue Feb 19, 2024 · 3 comments
Closed

Error when specifying size on cpu mode #472

SteHun opened this issue Feb 19, 2024 · 3 comments
Labels
bug Something isn't working planned

Comments

@SteHun
Copy link

SteHun commented Feb 19, 2024

I'm running it on Fedora linux 39 with Python venv 3.10.13 and Imaginairy 14.1.1. I also don't have a GPU on my machine (I know it's really slow but I have nothing better at the moment and I'm patient).

After running a command like this: imagine --size 1000x500 "any prompt" --steps 5 (I suppose it concerns the specification of size) I got this error.

Traceback (most recent call last):
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/cli/clickshell_mod.py", line 30, in invoke_
    command.main(
  File "<path>/venv/lib64/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "<path>/venv/lib64/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "<path>/venv/lib64/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "<path>/venv/lib64/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib64/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/cli/imagine.py", line 187, in imagine_cmd
    return _imagine_cmd(
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/cli/shared.py", line 220, in _imagine_cmd
    filenames = imagine_image_files(
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/api/generate.py", line 90, in imagine_image_files
    for result in imagine(
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/api/generate.py", line 237, in imagine
    result = generate_single_image(
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/api/generate_refiners.py", line 236, in generate_single_image
    comp_image, comp_img_orig = _generate_composition_image(
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/api/generate_refiners.py", line 599, in _generate_composition_image
    img = upscale_image(img, ultrasharp=True)
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/enhancers/upscale_realesrgan.py", line 47, in upscale_image
    upsampler_output, img_mode = realesrgan_upsampler(ultrasharp=ultrasharp).enhance(
  File "<path>/venv/lib64/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/vendored/realesrgan.py", line 253, in enhance
    self.pre_process(img)
  File "<path>/venv/lib64/python3.10/site-packages/imaginairy/vendored/realesrgan.py", line 115, in pre_process
    self.img = F.pad(self.img, (0, self.pre_pad, 0, self.pre_pad), "reflect")
  File "<path>/venv/lib64/python3.10/site-packages/torch/nn/functional.py", line 4495, in pad
    return torch._C._nn.pad(input, pad, mode, value)
RuntimeError: "reflection_pad2d" not implemented for 'Half'

After looking around on the internet, I found this issue. Searching through the code I found imaginairy/enhancers/upscale_realesrgan.py.py. Flipping half to False with the creation of a RealESRGANer object seemed to make it work again. Maybe it could check if the user is in cpu mode to flip this to False?
I'm not at all familiar with anything regarding image generation, let alone this specific project, so it might be a bad solution.

@brycedrennan
Copy link
Owner

brycedrennan commented Feb 20, 2024

Hey great job debugging that. I think you're correct in both the diagnosis and solution.

@brycedrennan brycedrennan added the bug Something isn't working label Feb 20, 2024
@brycedrennan
Copy link
Owner

We're in the process of totally rewriting the upscaling code and we'll check to see whether this situation still occurs.
#464

@brycedrennan
Copy link
Owner

Should be fixed now in 14.3.0. let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planned
Projects
None yet
Development

No branches or pull requests

2 participants