invoke-ai / InvokeAI

InvokeAI is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, supports terminal use through a CLI, and serves as the foundation for multiple commercial products.
https://invoke-ai.github.io/InvokeAI/
Apache License 2.0
22.78k stars 2.35k forks source link

RealESRGAN not working on M1 (upscaler) #297

Closed slk333 closed 1 year ago

slk333 commented 2 years ago

Hi, on Apple M1, Upscaler is not working:

Error running RealESRGAN - Your image was not upscaled.
'NoneType' object has no attribute 'enhance'
tildebyte commented 2 years ago

Is there more output? A complete traceback would be helpful...

MischaU8 commented 2 years ago

This happens because it detects that you have a CPU and won't load the upscaler: https://github.com/lstein/stable-diffusion/blob/main/ldm/gfpgan/gfpgan_tools.py#L78

slk333 commented 2 years ago

This happens because it detects that you have a CPU and won't load the upscaler: https://github.com/lstein/stable-diffusion/blob/main/ldm/gfpgan/gfpgan_tools.py#L78

Thanks, I think support for the upscaler is really important. I hope the macos fork will support it soon

@lstein @magnusviri

Any-Winter-4079 commented 2 years ago

How about using realesrgan-ncnn-vulkan? https://github.com/xinntao/Real-ESRGAN/releases This is from Prog Rock Stable and it works on M1

def esrgan_resize(input, id):
    input.save(f'_esrgan_orig{id}.png')
    try:
        subprocess.run(
            ['./realesrgan-ncnn-vulkan', '-i', '_esrgan_orig.png', '-o', '_esrgan_.png'],
            stdout=subprocess.PIPE
        ).stdout.decode('utf-8')
        output = Image.open('_esrgan_.png').convert('RGBA')
        return output
    except Exception as e:
        print('ESRGAN resize failed. Make sure realesrgan-ncnn-vulkan is in your path (or in this directory)')
        print(e)
        quit()
rcarmo commented 2 years ago

Yep. That works for me if I run it separately on my M1 Pro. Mind that it segfaults when it can't find the model files.

slk333 commented 1 year ago

it is now working (even though it does not run on MPS yet). closing this issue