glonlas / Stable-Diffusion-Apple-Silicon-M1-Install

Stable Diffusion Install script with GPU support for Apple Silicon M1/M2
48 stars 5 forks source link

upscaler ESRGAN not installed after clean install #1

Closed slk333 closed 1 year ago

slk333 commented 2 years ago

Hi, just tried your script. I used the web UI. I got this error in the terminal:

Error ESRGAN resize failed:
Traceback (most recent call last):
  File "/Users/antoineweber/stable-diffusion/stable-diffusion/ldm/gfpgan/gfpgan_tools.py", line 161, in real_esrgan_upscale
    subprocess.run(
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../realesrgan'

>> Error running RealESRGAN - Your image was not upscaled.
local variable 'res' referenced before assignment
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 52368)
Traceback (most recent call last):
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/http/server.py", line 425, in handle
    self.handle_one_request()
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/http/server.py", line 413, in handle_one_request
    method()
  File "/Users/antoineweber/stable-diffusion/stable-diffusion/ldm/dream/server.py", line 157, in do_POST
    self.model.prompt2image(prompt,
  File "/Users/antoineweber/stable-diffusion/stable-diffusion/ldm/simplet2i.py", line 420, in prompt2image
    image_callback(image, seed, upscaled=True)
  File "/Users/antoineweber/stable-diffusion/stable-diffusion/ldm/dream/server.py", line 102, in image_done
    path = pngwriter.save_image_and_prompt_to_png(image, f'{prompt} -S{seed}', name)
  File "/Users/antoineweber/stable-diffusion/stable-diffusion/ldm/dream/pngwriter.py", line 39, in save_image_and_prompt_to_png
    image.save(path, 'PNG', pnginfo=info)
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/site-packages/PIL/Image.py", line 2284, in save
    self._ensure_mutable()
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/site-packages/PIL/Image.py", line 601, in _ensure_mutable
    self.load()
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/site-packages/PIL/Image.py", line 843, in load
    return self.im.pixel_access(self.readonly)
  File "/Users/antoineweber/opt/anaconda3/envs/ldm/lib/python3.10/site-packages/PIL/_util.py", line 19, in __getattr__
    raise self.ex
ValueError: Operation on closed image
slk333 commented 2 years ago

I think the script didnt install RealESRGAN:

Screenshot 2022-09-07 at 18 18 50
slk333 commented 2 years ago

I had to re-run this section to install it

REALESRGAN_ARCHIVE="realesrgan.zip"
    mkdir $REALESRGAN_PATH
    cd $REALESRGAN_PATH

    echo -e "${ITEM}- Download Real-ESRGAN Project${RESET}"
    wget -q --show-progress $REALESRGAN_GITHUB_URL -O $REALESRGAN_ARCHIVE
    unzip $REALESRGAN_ARCHIVE &> /dev/null
    rm $REALESRGAN_ARCHIVE &> /dev/null
    chmod u+x $REALESRGAN_PATH/realesrgan-ncnn-vulkan
    echo -e "${SUCCESS}- Real-ESRGAN is installed in $REALESRGAN_PATH ${RESET}"
    echo -e "${WARNING}Because MacOS cannot verify the developer of “realesrgan-ncnn-vulkan”. MacOS will ask you if you want to trust it the first time your will use it.${RESET}"
    echo "If you do not want this tool on your system, feel free to delete the folder $REALESRGAN_PATH"
glonlas commented 1 year ago

Thank you @slk333 for the feedback. Your screenshot and the error message show that it was not installed. You did well to re-run these lines.

For my information what version of the script do you use? It is possible that I made a mistake in one install step.

slk333 commented 1 year ago

I used the main branch with the latest commit.

glonlas commented 1 year ago

@slk333 Do you still have this issue?

slk333 commented 1 year ago

Hi, I have not tried another clean install so I cannot say.

slk333 commented 1 year ago

Ok apparently the upscaler is installed only when we select the 4th option

Upscale a picture with Real-ESRGAN upscaler

I thought it would be installed by default

glonlas commented 1 year ago

It was intended to not have it installed per default as this app is not a developer certified app, hence I did not want to enforce user to install an uncertified app.

I will update the script to tell this is not installed per default